更新时间:2023-12-03 08:05:16
这是因为这些键根本不会调用此事件;所有按键操作都不会调用事件onkeypress
,但主要是在输入字符时(但也可以将Backspace视为代码点#8)。您可以使用事件keydown
,keyup
,onblure
(而不是Tab),在onfocus
(而不是Tab):
http://www.w3schools.com/tags/ref_eventattributes.asp [ ^ ],
http:// www.w3schools.com/tags/ev_onkeypress.asp [ ^ ]。-SA
This is because these keys don't invoke this event at all; the eventonkeypress
is not invoked on all key presses, but mostly when a character is input (but also, say, Backspace considered as code point #8). You can use the eventskeydown
,keyup
,onblure
(instead of Tab), ononfocus
(instead of Tab):
http://www.w3schools.com/tags/ref_eventattributes.asp[^],
http://www.w3schools.com/tags/ev_onkeypress.asp[^].—SA