Question

I am wondering why I am not able to find any help regarding the keyboard keyup/keydown events, I actually want to detect which key is been pressed by the user via keyboard on iphone while inputting the text in the UITextField.

Was it helpful?

Solution

You can use this delegate method to get the character that's being entered into a UITextField:

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

For example:

if ([string isEqualToString:@"z"]){
    // z is being typed.
}

Just make sure you've said your UITextField's delegate to the class file where you implement this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top