Key

open class Key

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

Constructors

Key
Link copied to clipboard
open fun Key(parent: Keyboard.Row)
Create an empty key with no attributes.
Key
Link copied to clipboard
open fun Key(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.

Functions

getCurrentDrawableState
Link copied to clipboard
open fun getCurrentDrawableState(): Array<Int>
Returns the drawable state for the key, based on the current state and type of the key.
isInside
Link copied to clipboard
open fun isInside(x: Int, y: Int): Boolean
Detects if a point falls inside this key.
onPressed
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.
onReleased
Link copied to clipboard
open fun onReleased(inside: Boolean)
Changes the pressed state of the key.
squaredDistanceFrom
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.

Properties

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