使用 javascript 检测硬件键盘存在的最佳跨浏览器和跨平台方法是什么?
What is the best cross-browser and cross-platform way to detect hardware keyboard presence with javascript?
这可能是一个老问题,但几个月前,我自己也在寻找解决方案.我正在构建一个消息传递系统,当有人在物理键盘上点击 Return 时应该发送消息,但当有人在虚拟键盘上点击 Return 时插入换行符.我解决它的方法是计算 keydown 和 keyup 事件之间的时间,并在 Return 被击中时获取平均值.
This may be an old question, but a few months ago, I was looking for a solution to this myself. I was building a messaging system which should send the message when someone hits Return on their physical keyboard, but inserts a newline when someone hits Return on a virtual keyboard. The way I solved it was by counting the time between keydown and keyup events and getting the average when Return was hit.
我终于开始在我的博客 这里一个>.
I finally got around to documenting it on my blog here.
这篇关于如何使用 javascript 检测硬件键盘的存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Angular 2/Typescript 中使用 IScrollUse IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
Anime.js 在 Ionic 3 项目中不起作用anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 项目中不起作用)
Ionic 3 - 使用异步数据更新 ObservableIonic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用异步数据更新 Observable)
Angular 2:在本地 .json 文件中找不到文件Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指令?)
将 ViewChild 用于动态元素 - Angular 2 &离子2Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(将 ViewChild 用于动态元素 - Angular 2 amp;离子2)