I am trying to press "windows" + ";" key using javaScript/Jquery.Is there any way to do that?
Asked
Active
Viewed 289 times
0
-
this is not really the place to seek suggestions for a "yes" answer question. – Mark Schultheiss Sep 12 '19 at 14:37
-
https://stackoverflow.com/q/26816306/125981 – Mark Schultheiss Sep 12 '19 at 14:39
1 Answers
0
You can create a new KeyboardEvent
with metaKey
and keyCode
properties set as following:
document.addEventListener('keypress', (event) => {
console.log('Meta Key?', event.metaKey);
console.log('Key Code', event.which);
});
document.dispatchEvent(new KeyboardEvent('keypress', {
metaKey: true, // On Windows, this is "window" key
keyCode: 44 // This is keyCode of comma on Windows-US
}))
BUT, I'm not sure about browser support of this behavior.
Here's the list of keyCode
s: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
Hope this helps.

Harun Yilmaz
- 8,281
- 3
- 24
- 35