flix

0.81.0

Key

enum Key with Eq, Order, ToStringSource
case Left
case Right
case Up
case Down
case Space
case Enter
case Escape
case Backspace
case F3
case Other(Int32)

A key, named rather than numbered.

The runtime translates AWT's keyCode into these, so no game code ever mentions a key code.

Instances

Eq, Order, ToString

Definitions

def digit(k: Key): Option[Int32]§ Source

The digit a key stands for, if it is one of the number keys.

AWT reports keyCode, and for the number row those values are ASCII digits, so this is a subtraction rather than a table.

def fromCode(code: Int32): Key§ Source

Translates an AWT key code.

The numbers are java.awt.event.KeyEvent's VK_ constants, which is also what Processing reported -- it passed AWT's codes straight through -- so this table did not have to change when the window did.

def letter(k: Key): Option[Char]§ Source

The letter a key stands for, if it is one of A-Z.

AWT reports keyCode, and for letters those values are ASCII uppercase, so this is a conversion rather than a table. It is also why initials are uppercase only: keyCode carries no shift state.

def nameCharacter(k: Key): Option[Char]§ Source

A character that may appear in a name: A-Z or 0-9.

Two separate lookups rather than one range, because keyCode puts the digits well below the letters and nothing sensible lies between them. Scores.clean accepts the same set on the way in from a file, so what can be typed and what can be stored agree.