iPhone 键盘 keydown/keyup 事件?

发布于 2024-09-25 04:12:15 字数 96 浏览 0 评论 0原文

我想知道为什么我无法找到有关键盘 keyup/keydown 事件的任何帮助,我实际上想检测用户在 UITextField 中输入文本时通过 iphone 上的键盘按下了哪个键。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末が日狂欢 2024-10-02 04:12:15

您可以使用此委托方法获取正在输入到 UITextField 中的字符:

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

For示例:

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

只需确保您已将 UITextField 的委托指定给实现此功能的类文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文