Windows 键盘键的 ascii 代码和功能键 (F1 - F12) 和其他键(如 shift、capslock、backspace、ctrl 等)的代码 [英] ascii codes for windows keyboard keys and the codes for function keys(F1 - F12) and other keys like shift,capslock,backspace,ctrl etc

查看:27
本文介绍了Windows 键盘键的 ascii 代码和功能键 (F1 - F12) 和其他键(如 shift、capslock、backspace、ctrl 等)的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了编写一个与键盘相关的应用程序,我想要我键盘上的按键的 ASCII 码列表.

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

这是一个 Windows 键盘:

It is a windows keyboard :

我可以从哪里获得代码?如果我能得到十六进制的代码,那就太好了.

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

推荐答案

您可以通过运行(注入)以下命令获取所有 keyCode 值(即使对于 Function 键)JavaScript 代码进入浏览器的控制台.粘贴以下代码,然后按 Enter.然后单击页面中的任意位置以将光标从控制台中移除.

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

代码如下:

    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);

这篇关于Windows 键盘键的 ascii 代码和功能键 (F1 - F12) 和其他键(如 shift、capslock、backspace、ctrl 等)的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆