Home > Article > Web Front-end > Detailed examples of how to use jquery keyboard events
This article mainly introduces relevant information on the detailed use of jquery keyboard events. It mainly introduces three methods such as keydown(), keyup(), and keypress(). Friends in need can refer to it. I hope it can help everyone.
Detailed explanation of how to use jquery keyboard events
jQuery has three functions to handle keyboard events. According to the order in which the events occur, they are:
jquery code:
1. keydown();
2. keyup();
3. keypress();
##keydown( )
keyup()
keypress( )
$('input').keydown(function(event){ alert(event.keyCode); });above In the code, event.keyCode can help us get what key we pressed. It returns the ascii code, such as the up, down, left and right keys, which are 38, 40, 37, 39 respectively
##
$(document).keypress(function(e) { if (e.ctrlKey && e.which == 13) $("form").submit(); }) ;
The above is the detailed content of Detailed examples of how to use jquery keyboard events. For more information, please follow other related articles on the PHP Chinese website!