Key

open class Key

Class for describing the position and characteristics of a single key in the keyboard.

Constructors

Link copied to clipboard
constructor(parent: Keyboard.Row)
Create an empty key with no attributes.
constructor(res: Resources, parent: Keyboard.Row, x: Int, y: Int, parser: XmlResourceParser)
Create a key with the given top-left coordinate and extract its attributes from the XML parser.

Properties

Link copied to clipboard
open var codes: Array<Int>
All the key codes (unicode or custom code) that this key could generate, zero'th being the most important.
Link copied to clipboard
open var edgeFlags: Int
Flags that specify the anchoring to edges of the keyboard for detecting touch events that are just out of the boundary of the key.
Link copied to clipboard
open var gap: Int
The horizontal gap before this key
Link copied to clipboard
open var height: Int
Height of the key, not including the gap
Link copied to clipboard
open var icon: Drawable
Icon to display instead of a label.
Link copied to clipboard
Preview version of the icon, for the preview popup
Link copied to clipboard
Label to display
Link copied to clipboard
open var modifier: Boolean
Whether this is a modifier key, such as Shift or Alt
Link copied to clipboard
open var on: Boolean
If this is a sticky key, is it on?
Link copied to clipboard
Popup characters
Link copied to clipboard
open var popupResId: Int
If this key pops up a mini keyboard, this is the resource id for the XML layout for that keyboard.
Link copied to clipboard
open var pressed: Boolean
The current pressed state of this key
Link copied to clipboard
Whether this key repeats itself when held down
Link copied to clipboard
open var sticky: Boolean
Whether this key is sticky, i.e.
Link copied to clipboard
open var text: CharSequence
Text to output when pressed.
Link copied to clipboard
open var width: Int
Width of the key, not including the gap
Link copied to clipboard
open var x: Int
X coordinate of the key in the keyboard layout
Link copied to clipboard
open var y: Int
Y coordinate of the key in the keyboard layout

Functions

Link copied to clipboard
Returns the drawable state for the key, based on the current state and type of the key.
Link copied to clipboard
open fun isInside(x: Int, y: Int): Boolean
Detects if a point falls inside this key.
Link copied to clipboard
open fun onPressed()
Informs the key that it has been pressed, in case it needs to change its appearance or state.
Link copied to clipboard
open fun onReleased(inside: Boolean)
Changes the pressed state of the key.
Link copied to clipboard
open fun squaredDistanceFrom(x: Int, y: Int): Int
Returns the square of the distance between the center of the key and the given point.