Javascript - How to create a keypress event?

后端 未结 4 1279
误落风尘
误落风尘 2021-01-29 09:24

I\'ve looked on the internet for this and all I can find are depreciated functions so before posting please check to make sure that the code you suggest isn\'t depreciated.

4条回答
  •  一个人的身影
    2021-01-29 10:17

    you can use a library called shortcut.js .. here is a link to their source code for downloading: http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js

    then run ur code by making this function:

    shortcut.add("Ctrl+K",function() {
        alert("Hi there!");
    });
    

    and here is the documentation : http://www.openjs.com/scripts/events/keyboard_shortcuts/

    hope that can help.

提交回复
热议问题