We are creating a web user interface that looks like a desktop window.
Now we need to handle the Alt key. When Alt key is pressed the focus goes to the upper menu.
In Javascript, how to get the event for Alt key when ONLY Alt key is pressed?
我需要确保没有同时按下其他键。
也许像这样
document.onkeydown = keydown;
function keydown(evt) {
if (!evt) evt = event;
if (evt.altKey) {
console.log('alt');
}
} // function keydown(evt)
<input type"text" onkeydown="keydown" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)