Class KeyHandler

java.lang.Object
net.vincent.parkourwarrior.KeyHandler
All Implemented Interfaces:
KeyListener, EventListener

public class KeyHandler extends Object implements KeyListener
Keyboard input handler for the game.

This class is for handling the keyboard input for the game, the Keyhandler class is universal for all modes, as it would determine the current state and send signals to the target method.

Since:
1.0
  • Constructor Details

    • KeyHandler

      public KeyHandler(ParkourMain parkourMain)
      Constructs a new KeyHandler with a reference to the main game panel.
      Parameters:
      parkourMain - the main game panel instance
      Since:
      1.0
  • Method Details

    • keyTyped

      public void keyTyped(KeyEvent e)
      Invoked when a key has been typed.
      Specified by:
      keyTyped in interface KeyListener
      Parameters:
      e - the KeyEvent to process
      Since:
      1.0
    • keyPressed

      public void keyPressed(KeyEvent e)
      Invoked when a key has been pressed.

      This method handles the key press events for the game, dispatching input to the appropriate game state handler (e.g. playing, title screen, finish screen).

      Specified by:
      keyPressed in interface KeyListener
      Parameters:
      e - the KeyEvent to process
      Since:
      1.0
    • keyReleased

      public void keyReleased(KeyEvent e)
      Invoked when a key has been released.

      This method handles key release events, stopping player movement and triggering momentum effects.

      Specified by:
      keyReleased in interface KeyListener
      Parameters:
      e - the KeyEvent to process
      Since:
      1.0