How to Get ASCII KeyCode of User Pressed Keys using JavaScript & jQuery

arp14 JavaScript, jQuery, Tutorial Tags: , , , 2

Hi everyone,

In this post, we are going to learn how to get ASCII KeyCode of User pressed keys using JavaScript and jQuery. Suppose we have an input tag with id “#textbox“. Now try the following codes and have fun.

JavaScript

document.getElementById("textbox").onkeyup = function (e) {
    alert(e.keyCode);
}

jQuery

$("#textbox").keyup(function(e) {
    alert(e.keyCode);
});

If you need any help regarding getting user pressed ASCII keycodes via JavaScript and jQuery, please comment below.

Thank you.

2 thoughts on “How to Get ASCII KeyCode of User Pressed Keys using JavaScript & jQuery

    1. Hi grandhi,
      Its working fine (device: Pantech Burst Stock ICS Default Browser).
      For alpha chars, I get false and For numbers, I get true.
      Which particular device you’re trying with?

Leave a Reply

Note: Your email address will not be published. Required fields are marked *