Is there a keyCode
for the Windows key or a way to detect when it is pressed with Javascript or jQuery?
I've dug through StackOverflow and have found how to detect command for Mac and Ctrl and Alt for Mac and Windows, but can't find any solutions for detecting when the user presses Windows Key. Not sure if it's just a metaKey
like command is but represented by the Windows Flag, or if it's even detectable at all.
Is there a keyCode
for the Windows key or a way to detect when it is pressed with Javascript or jQuery?
I've dug through StackOverflow and have found how to detect command for Mac and Ctrl and Alt for Mac and Windows, but can't find any solutions for detecting when the user presses Windows Key. Not sure if it's just a metaKey
like command is but represented by the Windows Flag, or if it's even detectable at all.
2 Answers
Reset to default 8VK_LWIN
0x5B - Left Windows key (Natural keyboard) EDIT: This explains Ed's answer as hex 5B
is 91
VK_RWIN 0x5C - Right Windows key (Natural keyboard)
SOURCE: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
Also, per wikipedia:
The Windows key can also be used on other operating systems.
On Unix and Unix-like operating systems, it is sometimes called "Meta" or "Super".
SOURCE: https://en.wikipedia.org/wiki/Windows_key#Use_with_non-Microsoft_operating_systems
I ran the following js and got 91 when pressing windows key.
document.onkeydown = function(evt){
console.log(evt.keyCode);
}
$.ui.keyCode
. For example you can check$.ui.keyCode.DOWN
instead of40
. – zzzzBov Commented Apr 6, 2016 at 18:06