问题描述
我有以下设置:
- 蓝牙扫描仪
- iPad
- 带有用于扫描输入的文本字段的网页
用法:
- 用户焦点文本字段并使用蓝牙扫描仪扫描条形码
- 扫描仪在扫描结束时添加 ENTER (13)
问题:
在 IOS7 中的 Safari 上,蓝牙设备上的键盘事件处理方式似乎发生了变化.代码...
On Safari in IOS7 there seems to be a change on how keyboard events are handled on bluetooth devices.The code ...
window.onkeyup = function (e) {
console.log(e.KeyboardEvent)
}
... 应该返回有关按下的键的信息.相反,我得到...
... should return information about the key pressed. Instead i get ...
keyCode: 0
keyIdentifier: "Unidentified"
...无论我按哪个键.
... no matter which key I press.
蓝牙扫描仪和蓝牙键盘的结果相同.
Same result booth form bluetooth scanner and bluetooth keyboard.
谢谢/E
推荐答案
不过似乎onkeypress"按预期工作.
Seems that "onkeypress" works as expected though.
由于这是 Sencha Touch 项目中的一个问题,而且 Sencha Touch 在文本字段上没有按键事件,因此我发布了解决我问题的代码.
Since this was a problem a bumbed in to in a Sencha Touch project and Sencha Touch doesn't have a keypress event on textfields I'm posting the code that solved my problem.
{
xtype:'searchfield',
name:'search',
placeHolder:'search',
listeners: {
painted: {
fn: function () {
var me = this;
me.element.dom.onkeypress = function (e) {
if (e.keyCode === 13) {
me.fireEvent('searchkeypress', me, e);
}
};
}
}
}
}
这篇关于来自蓝牙键盘的 IOS7 上 Safari 中的 onkeyup 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!