I'm using this (http://www.openjs.com/scripts/events/keyboard_shortcuts/) library to check keypress on my website.
I've made that code to switch a div's content whether the key is pressed or not. This sc开发者_运维技巧ript works.
shortcut.add("G",function() {
document.getElementById("loading").innerHTML = '123';
},{
'type':'keydown',
'propagate':true,
'target':document
});
shortcut.add("G",function() {
document.getElementById("loading").innerHTML = '456';
},{
'type':'keyup',
'propagate':true,
'target':document
});
Now when I want to check modifier keypress (For example Meta (=Command on Mac) or Ctrl), it doesn't work:
shortcut.add("Meta",function() {
document.getElementById("loading").innerHTML = '123';
},{
'type':'keydown',
'propagate':true,
'target':document
});
shortcut.add("Meta",function() {
document.getElementById("loading").innerHTML = '456';
},{
'type':'keyup',
'propagate':true,
'target':document
});
Is this a limitation of the library or am I doing something wrong? If it's because of the library, can somebody please show me what to add in the script?
精彩评论