In Javascript, I want to write a function that returns a list of all keys that are currently pressed (so that I can allow the user to create custom keyboard shortcuts.) Is there any way to obtain a list of all currently pressed keys in Javascript?
Share
keydownevent will be sentkeyupevent will be triggeredSo you just need to save the keys in an array and check whether your combination is true.
Example
Note that you should use
e.keyinstead ofe.keyCodewhenever possible (in this casevar key = {}, sincee.keyis a string).