开发者

Detect space and space + shift key press on iPhone Keyboard

开发者 https://www.devze.com 2023-02-03 06:24 出处:网络
I\'m trying to find a simple example to detect certain key events on the iPhone keyboard but 开发者_C百科am having trouble finding examples. Does anyone have simple examples? I\'m attempting to do a s

I'm trying to find a simple example to detect certain key events on the iPhone keyboard but 开发者_C百科am having trouble finding examples. Does anyone have simple examples? I'm attempting to do a simple substitution when the Space and Space+Shift keys are pressed.


You can use the shouldChangeTextInRange: delegate to detect characters:

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)string {

    if([string isEqualToString:@"  +"]) {

        /* do something  */

    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消