2

To write a keyboard related application I wanted the list of the ASCII codes of the keys that I have on my keyboard.

It is a windows keyboard :

enter image description here

From where can I get the codes ? It will be great if I get the codes in hexadecimal notation.

  • 1
    Which programing language are you using? These are already defined for languages like c# – nunespascal May 31 '12 at 11:17
  • @nunespascal java + c / JNI. Why did you ask this ? – saplingPro May 31 '12 at 11:18
  • 1
    What exactly do you mean by "ASCII codes"? For example, there's no "ASCII code" for "the F1 key" or "the Windows key". – Jon Skeet May 31 '12 at 11:19
  • @Jon Skeet what are the codes used to represent the function keys then,caps lock,shift,etc ? There will be some standard ? – saplingPro May 31 '12 at 11:22
4

This maybe too late,but I have a solution.You may get all the keyCode values (Even for Function keys) by running (injecting) following JavaScript code into your browser's console.simply paste the following code and press enter.Then click anywhere in the page to remove the cursor from the console.

Then press any key for which you want a keyCode in Hex

Here is the code :

    document.addEventListener("keydown", function (e) {
      code = (e.keyCode);
      console.log("In decimal "+e.keyCode);
      var hex = code.toString(16);
      console.log("In hex "+hex);
    }, false);
  • @samplingPro,please atleast accept any answer. – vertexion Aug 17 '13 at 18:26
1

There is no ascii code for the Function (F1-F12), Control, Windows or Alt keys.

If what you need is ASCII for the characters that is already defined in most languages.

Have a look at this, it also includes the hexadecimal codes

ASCII Tables with Hex

1

What you are looking for is called Scancode here and here. On linux there's a command showkey that can print a SCAN code of they pressed key. On Windows, though, you may need to write a program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.