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? I need to ensure that no other key was pressed at the same time.
Thanks in advance.
just put
e.preventDefault();
Working Demo
And your html may be like that
Note: If you want to get the alt event on other control/type than modify it with your requirements.
I don't know if this is the most elegant solution, but it worked fine.
maybe like this