jQuery Tutorial
event.keyCode
event.keyCode returns the Unicode value of a non-character key in a KeyPress events.
<html> <head> <title>The jQuery Example - To get key code</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type = "text/javascript"> function get_key_code(event) { var code = event.keyCode; $('span').text("Key code is: " + code); $('span').css('color', 'blue'); } </script> </head> <body> <p>Test Section</p> <p>Please enter the key to get pressed key code, <input type="text" onkeydown="get_key_code(event);"/></p> <p><span></span></p> </body> </html>Output:
event.keyCode- returns the pressed key code in the textbox.
here input a letter 'A' is pressed in the text field and returns a 'Key code is 65'.
« Previous Next » jQuery Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page