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

前端 未结 3 1820
春和景丽
春和景丽 2020-12-21 13:21

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 :

相关标签:
3条回答
  • 2020-12-21 13:35

    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.

    0 讨论(0)
  • 2020-12-21 13:41

    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

    0 讨论(0)
  • 2020-12-21 13:44

    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);
    
    0 讨论(0)
提交回复
热议问题