I am trying to create a method that will be triggered whenever any key on the keyboard is pressed, regardless of where the focus is. I want to be able to determine which key was pressed in this method.
Currently, I have set up an event listener for keydown events on 'input' elements using:
@keydown.native="keymonitor"
However, I would like the 'keymonitor' method to be invoked even when there is no focus on an input field, but the cursor is anywhere on the website and there is no specific focus.
Is there a way to achieve this? Adding the same event listener to a general div or the body element does not seem to work.
Thank you for your assistance.