Javascript 将键代码转换为字符

Javascript 将键代码转换为字符,javascript,Javascript,为什么某些键码会转换为其他字符 我认为219应该是[角色] onKeyPress I get 91 onKeyDown I get 219 firefox,测试页面: 更新:混淆是由onKeyPress和onKeyDown事件的按键代码产生的。 按下键返回字符代码(91),按下键返回键代码(219) 此表显示ascii码和键码(通过浏览器)。这是Unicode的。它将Unicode值转换为Unicode字符。W3P说: Definition and Usage The fromCharCo

为什么某些键码会转换为其他字符

我认为219应该是[角色]

onKeyPress I get 91
onKeyDown I get 219
firefox,测试页面:

更新:混淆是由onKeyPress和onKeyDown事件的按键代码产生的。 按下键返回字符代码(91),按下键返回键代码(219)


此表显示ascii码和键码(通过浏览器)。

这是Unicode的。它将Unicode值转换为Unicode字符。

W3P说:

Definition and Usage

The fromCharCode() method converts Unicode values into characters.

Note: This is a static method of the String object, and the syntax is always String.fromCharCode().
而不是
219
对于
[
字符,必须是
91


219
表示键码不是字符码

它转换为Unicode,这是转换表,用91代替

Vision有权,必须是
91
不是219这是一个测试页面,按一下键你可以得到字符码,按一下键你可以得到键盘键码。