简体   繁体   English

iOS:如何检测使用BT键盘时按下的任何键

[英]iOS : How to detect any key pressed when use a BT keyboard

I have to implement a manufacturer keyboard test app of iOS on iPad. 我必须在iPad上实现iOS的制造商键盘测试应用程序。

I am surveying on this topic right now. 我正在调查这个话题。

According to this article 根据这篇文章

[_myUITextField becomeFirstResponder];
[_myUITextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventAllEvents];
}

-(IBAction)textFieldDidChange:(id)sender{
    UITextField *_field = (UITextField *)sender;
    NSLog(@"%@",[_field text]);
}

With these code I can detect the letter(like 1,2,3,a,b,c...) I pressed in my app, but not all key pressed (like fn, ctl, cmd ...etc?) 使用这些代码,我可以检测到我在我的应用程序中按下的字母(如1,2,3,a,b,c ......),但不是所有键都按下了(如fn,ctl,cmd ......等?)

Anyone know how to achieve this...thanks^^ 任何人都知道如何实现这一点...谢谢^^

Try Notification center instead. 请尝试通知中心。

 NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

UITextField : UITextField:

[notificationCenter addObserver:self
                   selector:@selector (textFieldText:)
                       name:UITextFieldTextDidChangeNotification
                     object:yourtextfield];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检测iOS键盘上何时按下“ @ 123”按钮 - Detect when the “@123” button is pressed on the iOS keyboard 如何检测在iphone中按下的键盘键? - How to detect Keyboard key pressed in iphone? 如何在iOS的蓝牙键盘中检测何时按下播放按钮 - How can i detect when play button is pressed in a bluetooth keyboard in iOS 如何检测文本字段的键盘上按下了哪个键? - How can i detect which key was pressed on textfield's keyboard? UIWebview键盘返回键按下iOS 7 - UIWebview keyboard return key pressed ios 7 在UIWebView上按下键盘Enter键时如何捕获事件? - How to catch an event when keyboard Enter key is pressed on UIWebView? 如何检测长按退格键的时间? - How can I detect when the Backspace key is long pressed? iOS WatchKit - 如何检测Watch上何时按下后退按钮? - iOS WatchKit - How to detect when back button is pressed on Watch? 如何在 UITextField 的 iOS 键盘中检测大写锁定键敲击? - how to detect caps lock key tap in iOS keyboard for UITextField? 在iOS应用程序中,如何检测到用户已按下外部键盘上的箭头键之一? - Within an iOS app how do I detect that the user has pressed one of the arrow keys on their external keyboard?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM