If the user holds down the key, multiple keydown events are fired. For usability reasons I need to use keydown, not keyup, but I want to avoid this situation. My relevant co
Another simple adjustment to the accepted answer to allow for the multiple keys scenario:
var keyAllowed = {};
$(document).keydown(function(e) {
if (keyAllowed [e.which] === false) return;
keyAllowed [e.which] = false;
// code to be executed goes here
});
$(document).keyup(function(e) {
keyAllowed [e.which] = true;
});
$(document).focus(function(e) {
keyAllowed = {};
});