$("element").keydown(function(){
.....
})
Code to trigger Keydown event .
<script>
$(document).ready(function() {
$(document).keydown(function(){
alert('hi');
});
})
</script>
<script>
$(document).ready(function() {
//// keydown() ///
$(document).keydown(function(){
$('#d1').html('Keydown Event happened, keycode: '+ event.which);
$("#d1").show();
setTimeout(function() { $("#d1").fadeOut('slow'); }, 1000);
});
/////keypress() ///
$(document).keypress(function(){
$('#d2').html('Keypress Event happened, keycode: '+ event.which);
$("#d2").show();
setTimeout(function() { $("#d2").fadeOut('slow'); }, 1000);
});
///
});
</script>
HTML
<div id=d1></div> <div id=d2></div>
Most Popular JQuery Scripts | |
1 | Two dependant list boxes |
2 | Calendar with Date Selection |
3 | Data change by Slider |
4 | Show & Hide element |