How to detect Keyboard key pressed in iphone?

后端 未结 2 1994
故里飘歌
故里飘歌 2020-11-30 04:57

I want to detect whenever the user presses any keyboard key.

Any method which is called only on typing any character and not when keyboard is shown.

Thanks!!

2条回答
  •  没有蜡笔的小新
    2020-11-30 05:58

    Assuming the keyboard is showing as a result of the user tapping on a UITextfield, you can make yourself the delegate and implement this method:

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
    

    It will be called every time a user presses a key.

提交回复
热议问题