What\'s the easiest way to find the keycode for a specific key press?
Are there any good online tools that just capture any key event and show the code?
I wa
Just googled and result
function displayunicode(e) {
var unicode = e.keyCode ? e.keyCode : e.charCode;
console.log(unicode);
}
<form>
<input type="text" size="2" maxlength="1" onkeyup="displayunicode(event); this.select()" />
</form>
If you are looking for an online tool, https://keyjs.dev is probably the best option available:
By default, it displays e.key, e.code, e.which and e.keyCode for the keydown event.
If you need more than that, you can expand it and you will get a table with more properties for keydown, keypress and keyup.
If you still need more than that, open DevTools and you will see all the keys you press are logged to the console in a table-like style. Just click the row you are interested in to expand it and see the whole event object.
Disclaimer: I'm the author.
You can try use keycode.info to do this, it's an online tool.
Try this:
$('#myelement').keydown(function(event) {
var code = event.keyCode;
alert(code);
}
$(function () {
$(document).keyup(function (e) {
console.log(e.keyCode);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Here's your online tool.
Please try this.
$('input').on('keyup', function(e){
var key_code = e.which || e.keyCode;
console.log(key_code );
});
For better help please follow the below link http://www.w3schools.com/jsref/event_key_keycode.asp