# Keyboard.Key

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Key

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/inputmethodservice/Keyboard.Key "View this page in Java")  

```
open class Key
```

|---|------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                     ||
| ↳ | [android.inputmethodservice.Keyboard.Key](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#) |

*** ** * ** ***

| **This class was deprecated in API level 29.**
|
| Deprecated in Java.

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

## Summary

|                                                                                          XML attributes                                                                                          ||
|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
| [`android:codes`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)           | The unicode value or comma-separated values that this key outputs. |
| [`android:horizontalGap`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)   | Default horizontal gap between keys.                               |
| [`android:iconPreview`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)     | The icon to show in the popup preview.                             |
| [`android:isModifier`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)      | Whether this is a modifier key such as Alt or Shift.               |
| [`android:isRepeatable`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)    | Whether long-pressing on this key will make it repeat.             |
| [`android:isSticky`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)        | Whether this is a toggle key.                                      |
| [`android:keyEdgeFlags`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)    | Key edge flags.                                                    |
| [`android:keyHeight`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)       | Default height of a key, in pixels or percentage of display width. |
| [`android:keyIcon`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)         | The icon to display on the key instead of the label.               |
| [`android:keyLabel`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)        | The label to display on the key.                                   |
| [`android:keyOutputText`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)   | The string of characters to output when this key is pressed.       |
| [`android:keyWidth`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)        | Default width of a key, in pixels or percentage of display width.  |
| [`android:popupCharacters`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key) | The characters to display in the popup keyboard.                   |
| [`android:popupKeyboard`](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#attr_Key)   | The XML keyboard layout of any popup keyboard.                     |

|                                                                                                                                                                                                                                                                                                                                                                                                                                    Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Key](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#Key(android.content.res.Resources,%20android.inputmethodservice.Keyboard.Row,%20kotlin.Int,%20kotlin.Int,%20android.content.res.XmlResourceParser))`(`res:` `[Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources.html#)!`, `parent:` `[Keyboard.Row](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Row)!`, `x:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `y:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `parser:` `[XmlResourceParser](https://developer.android.com/reference/kotlin/android/content/res/XmlResourceParser.html#)!`)` Create a key with the given top-left coordinate and extract its attributes from the XML parser. |
| [Key](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#Key(android.inputmethodservice.Keyboard.Row))`(`parent:` `[Keyboard.Row](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Row)!`)` Create an empty key with no attributes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

|                                                                                                                                                                                                                                                    Public methods                                                                                                                                                                                                                                                     ||
|--------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)! | [getCurrentDrawableState](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#getCurrentDrawableState())`()` Returns the drawable state for the key, based on the current state and type of the key.                                                                                                                                                                                   |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [isInside](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#isInside(kotlin.Int,%20kotlin.Int))`(`x:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `y:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Detects if a point falls inside this key.                                                                   |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onPressed](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#onPressed())`()` Informs the key that it has been pressed, in case it needs to change its appearance or state.                                                                                                                                                                                                         |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onReleased](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#onReleased(kotlin.Boolean))`(`inside:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Changes the pressed state of the key.                                                                                                                                                   |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)             | [squaredDistanceFrom](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#squaredDistanceFrom(kotlin.Int,%20kotlin.Int))`(`x:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `y:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the square of the distance between the center of the key and the given point. |

|                                                                                                                                                                            Properties                                                                                                                                                                             ||
|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!               | [codes](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#codes:kotlin.IntArray) All the key codes (unicode or custom code) that this key could generate, zero'th being the most important.                            |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [edgeFlags](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#edgeFlags:kotlin.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. |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [gap](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#gap:kotlin.Int) The horizontal gap before this key                                                                                                             |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [height](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#height:kotlin.Int) Height of the key, not including the gap                                                                                                 |
| [Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.html#)! | [icon](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#icon:android.graphics.drawable.Drawable) Icon to display instead of a label.                                                                                  |
| [Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.html#)! | [iconPreview](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#iconPreview:android.graphics.drawable.Drawable) Preview version of the icon, for the preview popup                                                     |
| [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!       | [label](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#label:kotlin.CharSequence) Label to display                                                                                                                  |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                   | [modifier](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#modifier:kotlin.Boolean) Whether this is a modifier key, such as Shift or Alt                                                                             |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                   | [on](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#on:kotlin.Boolean) If this is a sticky key, is it on?                                                                                                           |
| [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!       | [popupCharacters](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#popupCharacters:kotlin.CharSequence) Popup characters                                                                                              |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [popupResId](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#popupResId:kotlin.Int) If this key pops up a mini keyboard, this is the resource id for the XML layout for that keyboard.                               |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                   | [pressed](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#pressed:kotlin.Boolean) The current pressed state of this key                                                                                              |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                   | [repeatable](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#repeatable:kotlin.Boolean) Whether this key repeats itself when held down                                                                               |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                   | [sticky](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#sticky:kotlin.Boolean) Whether this key is sticky, i.                                                                                                       |
| [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!       | [text](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#text:kotlin.CharSequence) Text to output when pressed.                                                                                                        |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [width](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#width:kotlin.Int) Width of the key, not including the gap                                                                                                    |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [x](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#x:kotlin.Int) X coordinate of the key in the keyboard layout                                                                                                     |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [y](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#y:kotlin.Int) Y coordinate of the key in the keyboard layout                                                                                                     |

## XML attributes

### android:codes

```
android:codes
```
The unicode value or comma-separated values that this key outputs. {@deprecated Copy this definition into your own application project.}

May be a string value, using '\\\\;' to escape characters such as '\\\\n' or '\\\\uxxxx' for a unicode character;

May be an integer value, such as "`100`".  

### android:horizontalGap

```
android:horizontalGap
```
Default horizontal gap between keys. {@deprecated Copy this definition into your own application project.}

May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "`14.5%`". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.  

### android:iconPreview

```
android:iconPreview
```
The icon to show in the popup preview. {@deprecated Copy this definition into your own application project.}

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:isModifier

```
android:isModifier
```
Whether this is a modifier key such as Alt or Shift. {@deprecated Copy this definition into your own application project.}

May be a boolean value, such as "`true`" or "`false`".  

### android:isRepeatable

```
android:isRepeatable
```
Whether long-pressing on this key will make it repeat. {@deprecated Copy this definition into your own application project.}

May be a boolean value, such as "`true`" or "`false`".  

### android:isSticky

```
android:isSticky
```
Whether this is a toggle key. {@deprecated Copy this definition into your own application project.}

May be a boolean value, such as "`true`" or "`false`".  

### android:keyEdgeFlags

```
android:keyEdgeFlags
```
Key edge flags. {@deprecated Copy this definition into your own application project.}

Must be one or more (separated by '\|') of the following constant values.

| Constant | Value |                                                     Description                                                     |
|----------|-------|---------------------------------------------------------------------------------------------------------------------|
| left     | 1     | Key is anchored to the left of the keyboard. {@deprecated Copy this definition into your own application project.}  |
| right    | 2     | Key is anchored to the right of the keyboard. {@deprecated Copy this definition into your own application project.} |

### android:keyHeight

```
android:keyHeight
```
Default height of a key, in pixels or percentage of display width. {@deprecated Copy this definition into your own application project.}

May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "`14.5%`". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.  

### android:keyIcon

```
android:keyIcon
```
The icon to display on the key instead of the label. {@deprecated Copy this definition into your own application project.}

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:keyLabel

```
android:keyLabel
```
The label to display on the key. {@deprecated Copy this definition into your own application project.}

May be a string value, using '\\\\;' to escape characters such as '\\\\n' or '\\\\uxxxx' for a unicode character;  

### android:keyOutputText

```
android:keyOutputText
```
The string of characters to output when this key is pressed. {@deprecated Copy this definition into your own application project.}

May be a string value, using '\\\\;' to escape characters such as '\\\\n' or '\\\\uxxxx' for a unicode character;  

### android:keyWidth

```
android:keyWidth
```
Default width of a key, in pixels or percentage of display width. {@deprecated Copy this definition into your own application project.}

May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "`14.5%`". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.  

### android:popupCharacters

```
android:popupCharacters
```
The characters to display in the popup keyboard. {@deprecated Copy this definition into your own application project.}

May be a string value, using '\\\\;' to escape characters such as '\\\\n' or '\\\\uxxxx' for a unicode character;  

### android:popupKeyboard

```
android:popupKeyboard
```
The XML keyboard layout of any popup keyboard. {@deprecated Copy this definition into your own application project.}

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".

## Public constructors

### Key

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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.

|                                                                                                                                        Parameters                                                                                                                                        ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `res`    | [Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources.html#)!:resources associated with the caller's context                                                                                                                                |
| `parent` | [Keyboard.Row](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Row)!:the row that this key belongs to. The row must already be attached to a[Keyboard](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard). |
| `x`      | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the x coordinate of the top-left                                                                                                                                                                    |
| `y`      | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the y coordinate of the top-left                                                                                                                                                                    |
| `parser` | [XmlResourceParser](https://developer.android.com/reference/kotlin/android/content/res/XmlResourceParser.html#)!:the XML parser containing the attributes for this key                                                                                                         |

### Key

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Key(parent: Keyboard.Row!)
```

Create an empty key with no attributes.

## Public methods

### getCurrentDrawableState

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getCurrentDrawableState(): IntArray!
```

**Deprecated:** *Deprecated in Java.*

Returns the drawable state for the key, based on the current state and type of the key.

|                                                         Return                                                         ||
|----------------------------------------------------------------------------------------|--------------------------------|
| [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)! | the drawable state of the key. |

**See Also**

- [android.graphics.drawable.StateListDrawable#setState(int[])](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.html#setState(kotlin.IntArray))  

### isInside

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun isInside(
    x: Int, 
    y: Int
): Boolean
```

**Deprecated:** *Deprecated in Java.*

Detects if a point falls inside this key.

|                                                  Parameters                                                   ||
|-----|----------------------------------------------------------------------------------------------------------|
| `x` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the x-coordinate of the point |
| `y` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the y-coordinate of the point |

|                                                                                                                                 Return                                                                                                                                 ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | whether or not the point falls inside the key. If the key is attached to an edge, it will assume that all points between the key and the edge are considered to be inside the key. |

### onPressed

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onPressed(): Unit
```

**Deprecated:** *Deprecated in Java.*

Informs the key that it has been pressed, in case it needs to change its appearance or state.  
**See Also**

- [#onReleased(boolean)](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#onReleased(kotlin.Boolean))  

### onReleased

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onReleased(inside: Boolean): Unit
```

**Deprecated:** *Deprecated in Java.*

Changes the pressed state of the key.

Toggled state of the key will be flipped when all the following conditions are fulfilled:

- This is a sticky key, that is,[sticky](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#sticky:kotlin.Boolean)is`true`.
- The parameter`inside`is`true`.
- [android.os.Build.VERSION#SDK_INT](https://developer.android.com/reference/kotlin/android/os/Build.VERSION.html#SDK_INT:kotlin.Int)is greater than[android.os.Build.VERSION_CODES#LOLLIPOP_MR1](https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#LOLLIPOP_MR1:kotlin.Int).

|                                                                                                      Parameters                                                                                                      ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `inside` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):whether the finger was released inside the key. Works only on Android M and later. See the method document for details. |

**See Also**

- <https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.Key#onPressed()>  

### squaredDistanceFrom

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun squaredDistanceFrom(
    x: Int, 
    y: Int
): Int
```

**Deprecated:** *Deprecated in Java.*

Returns the square of the distance between the center of the key and the given point.

|                                                  Parameters                                                   ||
|-----|----------------------------------------------------------------------------------------------------------|
| `x` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the x-coordinate of the point |
| `y` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the y-coordinate of the point |

|                                                                     Return                                                                     ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the square of the distance of the point from the center of the key |

## Properties

### codes

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var codes: IntArray!
```

**Deprecated:** *Deprecated in Java.*

All the key codes (unicode or custom code) that this key could generate, zero'th being the most important.  

### edgeFlags

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var edgeFlags: Int
```

**Deprecated:** *Deprecated in Java.*

Flags that specify the anchoring to edges of the keyboard for detecting touch events that are just out of the boundary of the key. This is a bit mask of[Keyboard.EDGE_LEFT](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard#EDGE_LEFT:kotlin.Int),[Keyboard.EDGE_RIGHT](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard#EDGE_RIGHT:kotlin.Int),[Keyboard.EDGE_TOP](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard#EDGE_TOP:kotlin.Int)and[Keyboard.EDGE_BOTTOM](https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard#EDGE_BOTTOM:kotlin.Int).  

### gap

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var gap: Int
```

**Deprecated:** *Deprecated in Java.*

The horizontal gap before this key  

### height

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var height: Int
```

**Deprecated:** *Deprecated in Java.*

Height of the key, not including the gap  

### icon

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var icon: Drawable!
```

**Deprecated:** *Deprecated in Java.*

Icon to display instead of a label. Icon takes precedence over a label  

### iconPreview

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var iconPreview: Drawable!
```

**Deprecated:** *Deprecated in Java.*

Preview version of the icon, for the preview popup  

### label

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var label: CharSequence!
```

**Deprecated:** *Deprecated in Java.*

Label to display  

### modifier

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var modifier: Boolean
```

**Deprecated:** *Deprecated in Java.*

Whether this is a modifier key, such as Shift or Alt  

### on

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var on: Boolean
```

**Deprecated:** *Deprecated in Java.*

If this is a sticky key, is it on?  

### popupCharacters

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var popupCharacters: CharSequence!
```

**Deprecated:** *Deprecated in Java.*

Popup characters  

### popupResId

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var popupResId: Int
```

**Deprecated:** *Deprecated in Java.*

If this key pops up a mini keyboard, this is the resource id for the XML layout for that keyboard.  

### pressed

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var pressed: Boolean
```

**Deprecated:** *Deprecated in Java.*

The current pressed state of this key  

### repeatable

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var repeatable: Boolean
```

**Deprecated:** *Deprecated in Java.*

Whether this key repeats itself when held down  

### sticky

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var sticky: Boolean
```

**Deprecated:** *Deprecated in Java.*

Whether this key is sticky, i.e., a toggle key  

### text

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var text: CharSequence!
```

**Deprecated:** *Deprecated in Java.*

Text to output when pressed. This can be multiple characters, like ".com"  

### width

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var width: Int
```

**Deprecated:** *Deprecated in Java.*

Width of the key, not including the gap  

### x

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var x: Int
```

**Deprecated:** *Deprecated in Java.*

X coordinate of the key in the keyboard layout  

### y

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var y: Int
```

**Deprecated:** *Deprecated in Java.*

Y coordinate of the key in the keyboard layout