gpt4 book ai didi

javascript - 将 Javascript 键代码转换为 Char,反之亦然

转载 作者:行者123 更新时间:2023-12-03 02:42:41 26 4
gpt4 key购买 nike

我正在研究 HTML 输入过滤,我遇到以下情况:

我需要将 keyCodes 转换为字符,但是当我处理数字键盘键时,我得到了奇怪的结果:

String.fromCharCode(96) //should be 0 but I recieve "`"
String.fromCharCode(97) //should be 1 but I recieve "a"
String.fromCharCode(98) //should be 2 but I receive "b"
String.fromCharCode(99) //should be 3 but I recieve "c"
String.fromCharCode(100) //should be 4 but I recieve "d"
String.fromCharCode(101) //should be 5 but I recieve "e"
String.fromCharCode(102) //should be 6 but I recieve "f"
String.fromCharCode(103) //should be 7 but I recieve "g"

从文档和事件调试中我可以看到以下映射:

numpad 0    96
numpad 1 97
numpad 2 98
numpad 3 99
numpad 4 100
numpad 5 101
numpad 6 102
numpad 7 103

链接:https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

我在这里缺少什么?

最佳答案

使用ASCII表获取字符代码。

关于javascript - 将 Javascript 键代码转换为 Char,反之亦然,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48254843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com