Match 3 Movement Using Keyboard Controls,Match 3 movement using keyboard controls

Hi, I currently have a match 3 game that works using the mouse. You click and drag the pieces to make a match and they disappear and the board refills accordingly like any match 3 game out there. What I want to do is have the arrow keys control what you can do with the mouse. For instance, the arrow keys will navigate the board and highlight the piece that the player is currently on, the player hits enter, selects the piece and presses the key to move it in the desired direction. How would I go about doing this? Any information will help, thank you!,

Unity offers a navigation system that works pretty well.
A UI Button, or any component that inherits from Selectable will receive navigation events Move, Cancel, Submit.

Here’s a quick test you can do :

  • Create a few UI Buttons
  • Assign one of them to the EventSystem “FirstSelected” field
  • Navigate with the keyboard.

By default, the EventSystem uses the Horizontal, Vertical, Submit and Cancel inputs from the Input Settings. And by default, the Input Settings have inputs for the keyboard and Joysticks.

Enter/Space = Submit

Esc = Cancel

You can also implement the ISelectHandler, IMoveHandler, ISubmitHandler and ICancelHandler instead of inheriting from Selectable.

If you find yourself in a situation where navigation becomes tricky, you can have a look at this extension on the AssetStore. I made it to make navigation easier through scroll views and complex ui schemes on consoles and other pointer less platforms.