jquery on keydown code example
Example 1: jquery on enter key pressed
//jQuery detect user pressing enter
$(document).on('keypress',function(e) {
if(e.which == 13) {
alert('User pressed Enter!');
}
});
Example 2: javascript keydown
document.addEventListener("keydown", function(event) {
if (event.keyCode == 32) {
console.log("Space was pressed!");
}
});
Example 3: keydown jquery
$(document).keydown(function(event) {
// Your code
});
Example 4: jquery on body click
$('body').on('click', '.anything', function() {