en.javascript.info/2-ui/4-forms-controls/2-focus-blur/5-keyboard-mouse/solution.md
2019-05-27 01:13:19 +10:00

6 lines
412 B
Markdown

We can use `mouse.onclick` to handle the click and make the mouse "moveable" with `position:fixed`, then `mouse.onkeydown` to handle arrow keys.
The only pitfall is that `keydown` only triggers on elements with focus. So we need to add `tabindex` to the element. As we're forbidden to change HTML, we can use `mouse.tabIndex` property for that.
P.S. We also can replace `mouse.onclick` with `mouse.onfocus`.