Interface SquidInput.KeyHandler

Enclosing class:
SquidInput

public static interface SquidInput.KeyHandler
A single-method interface used to process "typed" characters, special characters produced by unusual keys, and modifiers that can affect them. SquidInput has numerous static char values that are expected to be passed to handle() in place of the special keys (such as arrow keys) that do not have a standard char value.
  • Method Summary

    Modifier and Type Method Description
    void handle​(char key, boolean alt, boolean ctrl, boolean shift)
    The only method you need to implement yourself in KeyHandler, this should react to keys such as 'a' (produced by pressing the A key while not holding Shift), 'E' (produced by pressing the E key while holding Shift), and '←' (left arrow in unicode, also available as a constant in SquidInput, produced by pressing the left arrow key even though that key does not have a default unicode representation).
  • Method Details

    • handle

      void handle​(char key, boolean alt, boolean ctrl, boolean shift)
      The only method you need to implement yourself in KeyHandler, this should react to keys such as 'a' (produced by pressing the A key while not holding Shift), 'E' (produced by pressing the E key while holding Shift), and '←' (left arrow in unicode, also available as a constant in SquidInput, produced by pressing the left arrow key even though that key does not have a default unicode representation). Capital letters will be capitalized when they are passed to this, but they may or may not have the shift argument as true depending on how this method was called. Symbols that may be produced by holding Shift and pressing a number or a symbol key can vary between keyboards (some may require Shift to be held down, others may not).
      This can react to the input in whatever way you find appropriate for your game.
      Parameters:
      key - a char of the "typed" representation of the key, such as 'a' or 'E', or if there is no Unicode character for the key, an appropriate alternate character as documented in SquidInput.fromKey()
      alt - true if the Alt modifier was being held while this key was entered, false otherwise.
      ctrl - true if the Ctrl modifier was being held while this key was entered, false otherwise.
      shift - true if the Shift modifier was being held while this key was entered, false otherwise.