I am in the process of converting a game from Javascript/jQuery to Vue. This particular game is entirely controlled by keyboard input, with no mouse interaction involved.
Players navigate through the game using the "up" and "down" arrow keys to cycle through buttons, the "enter" key to select options, and the "back" arrow key to go back.
When a player selects an option, relevant data is stored in a "game" array so that during gameplay, the correct game and players can be displayed.
My question is, what would be the most effective way to implement this functionality in Vue?
I've come across information suggesting that using jQuery for DOM manipulation in a Vue project is not ideal. However, I'm unsure how to achieve the same functionality as keypress() does in jQuery across all pages without it.
This is the current structure of the page (designed to work with Javascript/jQuery):
// Initial page seen by the player
<div class="page1">
<div class="button button_selected" data-link="choosegame">Choose a game</div>
<div class="button" data-link="highscores">Highscores</div>
<div class="button" data-link="settings">Settings</div>
</div>
// If "Choose a game" is selected, display this page:
<div class="choosegame">
<div class="button" data-link="chooseplayers" data-options="{game:'checkers',players:'2',playersmax:'2'}">Checkers</div>
<div class="button" data-link="chooseplayers" data-options="{game:'bingo',playersmin:'2',playersmax:'4'}">Bingo</div>
<div class="button" data-link="chooseplayers" data-options="{game:'scrabble',players:'2',playersmax:'2'}">Scrabble</div>
</div>
// If a specific game is selected (e.g., checkers), display this page:
<div class="chooseplayers">
<div class="button" data-link="playgame" data-options="{player:'Jimmy'}">Jimmy</div>
<div class="button" data-link="playgame" data-options="{player:'Billy'}">Billy</div>
<div class="button" data-link="playgame" data-options="{player:'Arnold'}">Arnold</div>
</div>
// After players are selected, show this page:
<div class="playgame">
PLAYING!
</div>