aahrens
aahrens

Reputation: 5590

Detect space and space + shift key press on iPhone Keyboard

I'm trying to find a simple example to detect certain key events on the iPhone keyboard but 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.

Upvotes: 1

Views: 1137

Answers (1)

WrightsCS
WrightsCS

Reputation: 50707

You can use the shouldChangeTextInRange: delegate to detect characters:

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

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

        /* do something  */

    }
}

Upvotes: 1

Related Questions