Package codedraw
Class KeyPressEvent
java.lang.Object
codedraw.Event
codedraw.KeyPressEvent
This argument is given continuously while a key is being held down.
-
Method Summary
Modifier and TypeMethodDescriptionchar
getChar()
Gets the character representation of the key that was pressed.int
Returns the key code of the key pressed.getKey()
Gets the key that was pressed to trigger the event.boolean
Gets whether alt was pressed.boolean
Gets whether alt graph was pressed.boolean
Gets whether control was pressed.boolean
Gets whether shift was pressed.toString()
-
Method Details
-
getKey
Gets the key that was pressed to trigger the event. If the key is not found or unknown the key valueKey.UNDEFINED
will be used.- Returns:
- a key.
-
getChar
public char getChar()Gets the character representation of the key that was pressed. For example pressing the A key + SHIFT will result in an 'A', but without pressing SHIFT will result in a lowercase 'a'.- Returns:
- a char.
-
getExtendedKeyCode
public int getExtendedKeyCode()Returns the key code of the key pressed. The extended key code can be used to uniquely identify a key on a keyboard.- Returns:
- the key code.
-
isControlDown
public boolean isControlDown()Gets whether control was pressed.- Returns:
- true if control was pressed, otherwise false.
-
isAltDown
public boolean isAltDown()Gets whether alt was pressed.- Returns:
- true if alt was pressed, otherwise false.
-
isAltGraphDown
public boolean isAltGraphDown()Gets whether alt graph was pressed.- Returns:
- true if alt graph was pressed, otherwise false.
-
isShiftDown
public boolean isShiftDown()Gets whether shift was pressed.- Returns:
- true if shift was pressed, otherwise false.
-
toString
-