更改默认按键操作 JavaScript
可能的重复:
如何用 jQuery 替换击键?
我可以通过这种方式更改 JavaScript 中按键的默认字符。就像如果有人按下“E”按钮,它会打印出 ap ,这是实时的,就像它被输入到文本区域一样。无论如何,用 jQuery 或类似的东西来做到这一点?谢谢!
Possible Duplicate:
How do I replace a keystroke with jQuery?
Is there a way where I can change the default character of a key pressed in JavaScript. Like if somebody presses the "E" Button, it will print out a p instead, and this is live, so like its being typed into a textarea. Anyway to do this with jQuery or anything like that? Thnaks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个工作解决方案的完整示例,基于 此 回答:
Here is a complete example of a working solution, based on this answer:
查看此框架以添加键盘快捷键。
http://www.openjs.com/scripts/events/keyboard_shortcuts/
当然它不会自动将任何按键转换为另一个字符并输出该字符,您必须弄清楚页面的哪个部分具有焦点,例如文本字段,并用您实际想要输入的字符修改它的值。
Check out this framework for adding keyboard shortcuts.
http://www.openjs.com/scripts/events/keyboard_shortcuts/
Of course it won't automatically convert any keypress to another character and output that character, you will have to figure out what part of the page has focus, for instance a text field, and modify it's value with what ever character you actually want to be inputed.