the*_*hai 6 javascript keyboard-events
当客户端在选项之间移动时,为什么不会触发键盘事件select?是否还发送了其他事件?
如何重现:
结果:当您使用向上/向下键盘键浏览选项时,不会发送任何事件。
超文本标记语言
<!-- The second value will be selected initially -->
<select name="text"> <!--Supplement an id here instead of using 'text'-->
<option value="value1">Value 1</option>
<option value="value2" selected>Value 2</option>
<option value="value3">Value 3</option>
</select>
Run Code Online (Sandbox Code Playgroud)
JS
function onkeyEvent(evt ){
console.log(evt);
}
window.addEventListener('keyup', onkeyEvent, true);
window.addEventListener('keydown', onkeyEvent, true);
window.addEventListener('keypress', onkeyEvent, true);
Run Code Online (Sandbox Code Playgroud)
仅在选择选项后才会触发更改事件,而不是在客户端选择(在选项中移动)时触发,因此我不接受它作为答案。