Detect key press on virtual keyboard

后端 未结 3 1531
别那么骄傲
别那么骄傲 2020-12-20 10:05

I am working on a small children\'s game for my son that involves timing on the virtual keyboard.

Is possible to detect when a key on the virtual keyboard is presse

3条回答
  •  -上瘾入骨i
    2020-12-20 10:20

    For TextView you can use...

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
    - (void)textViewDidChange:(UITextView *)textView
    

    For TextField you can use...

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

    See UITextViewDelegate and UITextFieldDelegate on Apple website.

提交回复
热议问题