Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

ascii codes for windows keyboard keys and the codes for function keys(F1 - F12) and other keys like shift,capslock,backspace,ctrl etc

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can get all the keyCode values (even for Function keys) by running (injecting) following JavaScript code into your browser's console. 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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...