en.javascript.info/2-ui/3-event-details/5-keyboard-events/2-check-sync-keydown/solution.md
Ilya Kantor 9bfd54a148 minor
2019-08-18 11:59:31 +03:00

6 lines
316 B
Markdown

We should use two handlers: `document.onkeydown` and `document.onkeyup`.
Let's create a set `pressed = new Set()` to keep currently pressed keys.
The first handler adds to it, while the second one removes from it. Every time on `keydown` we check if we have enough keys pressed, and run the function if it is so.