keydown jquery code example
Example 1: keydown jquery
$(document).keydown(function(event) {
// Your code
});
Example 2: keydown events
eventTarget.addEventListener("keydown", event => {
if (event.isComposing || event.keyCode === 229) {
return;
}
// do something
});
Example 3: keydown events
document.addEventListener('keydown', logKey);
function logKey(e) {
log.textContent += ` ${e.code}`;
}
Example 4: jquery keyup
// Similar to KeyUp but just called on input change (optimal for AJAX calls)
var input = $('#formID').find('input[type="text"]');
input.on('input',
function(){
console.log (input.val());
});