【发布时间】:2015-02-16 20:15:40
【问题描述】:
当专注于某个输入时, 用户按下某种组合键,例如“ctrl+e”, 我想在输入中显示“ctrl+e”。
下次用户按下另一个组合键时, 它会清理输入并显示新的。
我怎样才能做到这一点? 我在寻找一些 javascript 插件, 但它们最适合检测某些输入。
像这样: https://github.com/OscarGodson/jKey
$("input").jkey("i",function(){
jkey.log("You pressed the i key inside of an input.");
});
非常感谢。
【问题讨论】:
-
你需要听onkeypress或onkeydown。见this answer
标签: javascript jquery keyboard