This commit is contained in:
Ilya Kantor 2019-08-18 11:59:31 +03:00
parent 5d1037cbd0
commit 9bfd54a148
2 changed files with 22 additions and 19 deletions

View file

@ -1,6 +1,6 @@
We should use two handlers: `document.onkeydown` and `document.onkeyup`.
The set `pressed` should keep currently pressed keys.
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.