⏰ 15 mins
- For this exercise, I’ve hidden the profile form and included a button that allows the user to toggle its appearance. This already works great.
- Your task is to create some keyboard shortcuts that do the same thing.
esc - hide the form
⌘ + e or ⊞ + e on windows - show the form
<aside>
💡 HINT: you can use e.metaKey to check for ⌘ or ⊞
</aside>
<aside>
💡 HINT: you can use e.key to check for which key has been pressed. Use console log to test that
</aside>
- You should use Vue’s lifecycle hooks to add a
keydown listener to the window and make sure to remove it whenever the current page component is no longer in use
keyboard-shortcuts.mp4
Helpful Resources
- Vue.js Docs - Lifecycle Hooks
- MDN Docs - addEventListener
- MDN Docs - removeEventListener
- MDN Docs - Keydown Event