Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/view/KeyCharacterMap#nestedclasses) \| [Constants](https://developer.android.com/reference/android/view/KeyCharacterMap#constants) \| [Inherited Constants](https://developer.android.com/reference/android/view/KeyCharacterMap#inhconstants) \| [Fields](https://developer.android.com/reference/android/view/KeyCharacterMap#lfields) \| [Methods](https://developer.android.com/reference/android/view/KeyCharacterMap#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/view/KeyCharacterMap#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/KeyCharacterMap#inhmethods)

# KeyCharacterMap

*** ** * ** ***

` public class KeyCharacterMap `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/android/os/Parcelable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.KeyCharacterMap |

<br />

*** ** * ** ***

Describes the keys provided by a keyboard device and their associated labels.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/view/KeyCharacterMap.KeyData` *This class was deprecated in API level 11. instead use `https://developer.android.com/reference/android/view/KeyCharacterMap#getDisplayLabel(int)`, `https://developer.android.com/reference/android/view/KeyCharacterMap#getNumber(int)` and `https://developer.android.com/reference/android/view/KeyCharacterMap#get(int,%20int)`.* |
| ` class` | `https://developer.android.com/reference/android/view/KeyCharacterMap.UnavailableException` Thrown by `https://developer.android.com/reference/android/view/KeyCharacterMap#load(int)` when a key character map could not be loaded. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#ALPHA` A keyboard with all the letters, and maybe some numbers. |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#BUILT_IN_KEYBOARD` *This constant was deprecated in API level 15. This constant should no longer be used because there is no guarantee that a device has a built-in keyboard that can be used for typing text. There might not be a built-in keyboard, the built-in keyboard might be a `https://developer.android.com/reference/android/view/KeyCharacterMap#NUMERIC` or `https://developer.android.com/reference/android/view/KeyCharacterMap#SPECIAL_FUNCTION` keyboard, or there might be multiple keyboards installed including external keyboards. When interpreting key presses received from the framework, applications should use the device id specified in the `https://developer.android.com/reference/android/view/KeyEvent` received. When synthesizing key presses for delivery elsewhere or when translating key presses from unknown keyboards, applications should use the special `https://developer.android.com/reference/android/view/KeyCharacterMap#VIRTUAL_KEYBOARD` device id.* |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#COMBINING_ACCENT` <br /> |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#COMBINING_ACCENT_MASK` Mask the return value from `https://developer.android.com/reference/android/view/KeyCharacterMap#get(int,%20int)` with this value to get a printable representation of the accent character of a "dead key." |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#FULL` A full PC-style keyboard. |
| `char` | `https://developer.android.com/reference/android/view/KeyCharacterMap#HEX_INPUT` This private-use character is used to trigger Unicode character input by hex digits. |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#MODIFIER_BEHAVIOR_CHORDED` Modifier keys may be chorded with character keys. |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED` Modifier keys may be chorded with character keys or they may toggle into latched or locked states when pressed independently. |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#NUMERIC` A numeric (12-key) keyboard. |
| `char` | `https://developer.android.com/reference/android/view/KeyCharacterMap#PICKER_DIALOG_INPUT` This private-use character is used to bring up a character picker for miscellaneous symbols. |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#PREDICTIVE` A keyboard with all the letters, but with more than one letter per key. |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#SPECIAL_FUNCTION` A keyboard that is only used to control special functions rather than for typing. |
| `int` | `https://developer.android.com/reference/android/view/KeyCharacterMap#VIRTUAL_KEYBOARD` The id of a generic virtual keyboard with a full layout that can be used to synthesize key events. |

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor.
`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`".

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/view/KeyCharacterMap>` | `https://developer.android.com/reference/android/view/KeyCharacterMap#CREATOR` <br /> |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` static boolean` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#deviceHasKey(int)(int keyCode) ` Queries the framework about whether any physical keys exist on any currently attached input devices that are capable of producing the given key code. |
| ` static boolean[]` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#deviceHasKeys(int[])(int[] keyCodes) ` Queries the framework about whether any physical keys exist on any currently attached input devices that are capable of producing the given array of key codes. |
| ` boolean` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. |
| ` int` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#get(int,%20int)(int keyCode, int metaState) ` Gets the Unicode character generated by the specified key and meta key state combination. |
| ` static int` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getDeadChar(int,%20int)(int accent, int c) ` Get the character that is produced by combining the dead key producing accent with the key producing character c. |
| ` char` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getDisplayLabel(int)(int keyCode) ` Gets the primary character for this key. |
| ` https://developer.android.com/reference/android/view/KeyEvent` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getEvents(char[])(char[] chars) ` Get an array of KeyEvent objects that if put into the input stream could plausibly generate the provided sequence of characters. |
| ` boolean` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getKeyData(int,%20android.view.KeyCharacterMap.KeyData)(int keyCode, https://developer.android.com/reference/android/view/KeyCharacterMap.KeyData results) ` *This method was deprecated in API level 15. instead use `https://developer.android.com/reference/android/view/KeyCharacterMap#getDisplayLabel(int)`, `https://developer.android.com/reference/android/view/KeyCharacterMap#getNumber(int)` or `https://developer.android.com/reference/android/view/KeyCharacterMap#get(int,%20int)`.* |
| ` int` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getKeyboardType()() ` Gets the keyboard type. |
| ` char` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getMatch(int,%20char[],%20int)(int keyCode, char[] chars, int metaState) ` Gets the first character in the character array that can be generated by the specified key code. |
| ` char` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getMatch(int,%20char[])(int keyCode, char[] chars) ` Gets the first character in the character array that can be generated by the specified key code. |
| ` int` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getModifierBehavior()() ` Gets a constant that describes the behavior of this keyboard's modifier keys such as `https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_SHIFT_LEFT`. |
| ` char` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#getNumber(int)(int keyCode) ` Gets the number or symbol associated with the key. |
| ` boolean` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#isPrintingKey(int)(int keyCode) ` Returns true if the specified key produces a glyph. |
| ` static https://developer.android.com/reference/android/view/KeyCharacterMap` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#load(int)(int deviceId) ` Loads the key character maps for the keyboard with the specified device id. |
| ` void` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel out, int flags) ` Flatten this object in to a Parcel. |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/KeyCharacterMap#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/os/Parcelable ` ` abstract int` ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() `

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
` abstract void` ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) `

Flatten this object in to a Parcel.

## Constants

### ALPHA

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

```
public static final int ALPHA
```

A keyboard with all the letters, and maybe some numbers.

An alphabetic keyboard supports text entry directly but may have a condensed layout with a small form factor. In contrast to a `https://developer.android.com/reference/android/view/KeyCharacterMap#FULL`, some symbols may only be accessible using special on-screen character pickers. In addition, to improve typing speed and accuracy, the framework provides special affordances for alphabetic keyboards such as auto-capitalization and toggled / locked shift and alt keys.

This type of keyboard is generally designed for thumb typing.

<br />

<br />

Constant Value: 3 (0x00000003)

### BUILT_IN_KEYBOARD

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

```
public static final int BUILT_IN_KEYBOARD
```

<br />

**This constant was deprecated in API level 15.**   

This constant should no longer be used because there is no guarantee that a device has a built-in keyboard that can be used for typing text. There might not be a built-in keyboard, the built-in keyboard might be a `https://developer.android.com/reference/android/view/KeyCharacterMap#NUMERIC` or `https://developer.android.com/reference/android/view/KeyCharacterMap#SPECIAL_FUNCTION` keyboard, or there might be multiple keyboards installed including external keyboards. When interpreting key presses received from the framework, applications should use the device id specified in the `https://developer.android.com/reference/android/view/KeyEvent` received. When synthesizing key presses for delivery elsewhere or when translating key presses from unknown keyboards, applications should use the special `https://developer.android.com/reference/android/view/KeyCharacterMap#VIRTUAL_KEYBOARD` device id.

The id of the device's primary built in keyboard is always 0.

<br />

Constant Value: 0 (0x00000000)

### COMBINING_ACCENT

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

```
public static final int COMBINING_ACCENT
```

<br />

<br />

Constant Value: -2147483648 (0x80000000)

### COMBINING_ACCENT_MASK

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

```
public static final int COMBINING_ACCENT_MASK
```

Mask the return value from `https://developer.android.com/reference/android/view/KeyCharacterMap#get(int,%20int)` with this value to get a printable representation of the accent character of a "dead key."

<br />

Constant Value: 2147483647 (0x7fffffff)

### FULL

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

```
public static final int FULL
```

A full PC-style keyboard.

A full keyboard behaves like a PC keyboard. All symbols are accessed directly by pressing keys on the keyboard without on-screen support or affordances such as auto-capitalization.

This type of keyboard is generally designed for full two hand typing.

<br />

<br />

Constant Value: 4 (0x00000004)

### HEX_INPUT

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

```
public static final char HEX_INPUT
```

This private-use character is used to trigger Unicode character input by hex digits.

<br />

Constant Value: 61184 (0x0000ef00)

### MODIFIER_BEHAVIOR_CHORDED

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

```
public static final int MODIFIER_BEHAVIOR_CHORDED
```

Modifier keys may be chorded with character keys.

<br />

**See also:**

- `https://developer.android.com/reference/android/view/KeyCharacterMap#getModifierBehavior()`

Constant Value: 0 (0x00000000)

### MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED

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

```
public static final int MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED
```

Modifier keys may be chorded with character keys or they may toggle into latched or locked states when pressed independently.

<br />

**See also:**

- `https://developer.android.com/reference/android/view/KeyCharacterMap#getModifierBehavior()`

Constant Value: 1 (0x00000001)

### NUMERIC

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

```
public static final int NUMERIC
```

A numeric (12-key) keyboard.

A numeric keyboard supports text entry using a multi-tap approach. It may be necessary to tap a key multiple times to generate the desired letter or symbol.

This type of keyboard is generally designed for thumb typing.

<br />

<br />

Constant Value: 1 (0x00000001)

### PICKER_DIALOG_INPUT

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

```
public static final char PICKER_DIALOG_INPUT
```

This private-use character is used to bring up a character picker for miscellaneous symbols.

<br />

Constant Value: 61185 (0x0000ef01)

### PREDICTIVE

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

```
public static final int PREDICTIVE
```

A keyboard with all the letters, but with more than one letter per key.

This type of keyboard is generally designed for thumb typing.

<br />

<br />

Constant Value: 2 (0x00000002)

### SPECIAL_FUNCTION

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

```
public static final int SPECIAL_FUNCTION
```

A keyboard that is only used to control special functions rather than for typing.

A special function keyboard consists only of non-printing keys such as HOME and POWER that are not actually used for typing.

<br />

<br />

Constant Value: 5 (0x00000005)

### VIRTUAL_KEYBOARD

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

```
public static final int VIRTUAL_KEYBOARD
```

The id of a generic virtual keyboard with a full layout that can be used to synthesize key events. Typically used with `https://developer.android.com/reference/android/view/KeyCharacterMap#getEvents(char[])`.

<br />

Constant Value: -1 (0xffffffff)

## Fields

### CREATOR

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

```
public static final Creator<KeyCharacterMap> CREATOR
```

<br />

<br />

## Public methods

### describeContents

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

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`, the return value of this method must include the `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### deviceHasKey

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

```
public static boolean deviceHasKey (int keyCode)
```

Queries the framework about whether any physical keys exist on any currently attached input devices that are capable of producing the given key code.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The key code to query. <br /> |

| Returns ||
|---|---|
| `boolean` | True if at least one attached keyboard supports the specified key code. <br /> |

### deviceHasKeys

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

```
public static boolean[] deviceHasKeys (int[] keyCodes)
```

Queries the framework about whether any physical keys exist on any currently attached input devices that are capable of producing the given array of key codes.

<br />

| Parameters ||
|---|---|
| `keyCodes` | `int`: The array of key codes to query. <br /> |

| Returns ||
|---|---|
| `boolean[]` | A new array of the same size as the key codes array whose elements are set to true if at least one attached keyboard supports the corresponding key code at the same index in the key codes array. <br /> |

### equals

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

```
public boolean equals (Object obj)
```

Indicates whether some other object is "equal to" this one.

The `equals` method implements an equivalence relation on non-null object references:

- It is *reflexive*: for any non-null reference value `x`, `x.equals(x)` should return `true`.
- It is *symmetric*: for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
- It is *transitive*: for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
- It is *consistent*: for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
- For any non-null reference value `x`, `x.equals(null)` should return `false`.

An equivalence relation partitions the elements it operates on into *equivalence classes*; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### get

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

```
public int get (int keyCode, 
                int metaState)
```

Gets the Unicode character generated by the specified key and meta key state combination.

Returns the Unicode character that the specified key would produce when the specified meta bits (see `https://developer.android.com/reference/android/text/method/MetaKeyKeyListener`) were active.

Returns 0 if the key is not one that is used to type Unicode characters.

If the return value has bit `https://developer.android.com/reference/android/view/KeyCharacterMap#COMBINING_ACCENT` set, the key is a "dead key" that should be combined with another to actually produce a character -- see `https://developer.android.com/reference/android/view/KeyCharacterMap#getDeadChar(int,%20int)` -- after masking with `https://developer.android.com/reference/android/view/KeyCharacterMap#COMBINING_ACCENT_MASK`.

<br />

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The key code. <br /> |
| `metaState` | `int`: The meta key modifier state. <br /> |

| Returns ||
|---|---|
| `int` | The associated character or combining accent, or 0 if none. <br /> |

### getDeadChar

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

```
public static int getDeadChar (int accent, 
                int c)
```

Get the character that is produced by combining the dead key producing accent with the key producing character c. For example, getDeadChar('\`', 'e') returns è. getDeadChar('\^', ' ') returns '\^' and getDeadChar('\^', '\^') returns '\^'.

<br />

| Parameters ||
|---|---|
| `accent` | `int`: The accent character. eg. '\`' <br /> |
| `c` | `int`: The basic character. <br /> |

| Returns ||
|---|---|
| `int` | The combined character, or 0 if the characters cannot be combined. <br /> |

### getDisplayLabel

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

```
public char getDisplayLabel (int keyCode)
```

Gets the primary character for this key. In other words, the label that is physically printed on it.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The key code. <br /> |

| Returns ||
|---|---|
| `char` | The display label character, or 0 if none (eg. for non-printing keys). <br /> |

### getEvents

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

```
public KeyEvent[] getEvents (char[] chars)
```

Get an array of KeyEvent objects that if put into the input stream could plausibly generate the provided sequence of characters. It is not guaranteed that the sequence is the only way to generate these events or that it is optimal.

This function is primarily offered for instrumentation and testing purposes. It may fail to map characters to key codes. In particular, the key character map for the `https://developer.android.com/reference/android/view/KeyCharacterMap#BUILT_IN_KEYBOARD` device id may be empty. Consider using the key character map associated with the `https://developer.android.com/reference/android/view/KeyCharacterMap#VIRTUAL_KEYBOARD` device id instead.

For robust text entry, do not use this function. Instead construct a `https://developer.android.com/reference/android/view/KeyEvent` with action code `https://developer.android.com/reference/android/view/KeyEvent#ACTION_MULTIPLE` that contains the desired string using `https://developer.android.com/reference/android/view/KeyEvent#KeyEvent(long,%20java.lang.String,%20int,%20int)`.

<br />

<br />

| Parameters ||
|---|---|
| `chars` | `char`: The sequence of characters to generate. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/KeyEvent` | An array of `https://developer.android.com/reference/android/view/KeyEvent` objects, or null if the given char array can not be generated using the current key character map. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the passed array of characters is null. |

### getKeyData

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

```
public boolean getKeyData (int keyCode, 
                KeyCharacterMap.KeyData results)
```

<br />

**This method was deprecated in API level 15.**   

instead use `https://developer.android.com/reference/android/view/KeyCharacterMap#getDisplayLabel(int)`, `https://developer.android.com/reference/android/view/KeyCharacterMap#getNumber(int)` or `https://developer.android.com/reference/android/view/KeyCharacterMap#get(int,%20int)`.

Get the character conversion data for a given key code.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The keyCode to query. <br /> |
| `results` | `KeyCharacterMap.KeyData`: A `https://developer.android.com/reference/android/view/KeyCharacterMap.KeyData` instance that will be filled with the results. <br /> |

| Returns ||
|---|---|
| `boolean` | True if the key was mapped. If the key was not mapped, results is not modified. <br /> |

### getKeyboardType

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

```
public int getKeyboardType ()
```

Gets the keyboard type. Returns `https://developer.android.com/reference/android/view/KeyCharacterMap#NUMERIC`, `https://developer.android.com/reference/android/view/KeyCharacterMap#PREDICTIVE`, `https://developer.android.com/reference/android/view/KeyCharacterMap#ALPHA`, `https://developer.android.com/reference/android/view/KeyCharacterMap#FULL` or `https://developer.android.com/reference/android/view/KeyCharacterMap#SPECIAL_FUNCTION`.

Different keyboard types have different semantics. Refer to the documentation associated with the keyboard type constants for details.

<br />

<br />

| Returns ||
|---|---|
| `int` | The keyboard type. <br /> |

### getMatch

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

```
public char getMatch (int keyCode, 
                char[] chars, 
                int metaState)
```

Gets the first character in the character array that can be generated by the specified key code. If there are multiple choices, prefers the one that would be generated with the specified meta key modifier state.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The key code. <br /> |
| `chars` | `char`: The array of matching characters to consider. <br /> |
| `metaState` | `int`: The preferred meta key modifier state. <br /> |

| Returns ||
|---|---|
| `char` | The matching associated character, or 0 if none. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the passed array of characters is null. |

### getMatch

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

```
public char getMatch (int keyCode, 
                char[] chars)
```

Gets the first character in the character array that can be generated by the specified key code.

This is a convenience function that returns the same value as `https://developer.android.com/reference/android/view/KeyCharacterMap#getMatch(int,%20char[],%20int)`.

<br />

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The keycode. <br /> |
| `chars` | `char`: The array of matching characters to consider. <br /> |

| Returns ||
|---|---|
| `char` | The matching associated character, or 0 if none. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the passed array of characters is null. |

### getModifierBehavior

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

```
public int getModifierBehavior ()
```

Gets a constant that describes the behavior of this keyboard's modifier keys such as `https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_SHIFT_LEFT`.

Currently there are two behaviors that may be combined:

- Chorded behavior: When the modifier key is pressed together with one or more character keys, the keyboard inserts the modified keys and then resets the modifier state when the modifier key is released.
- Toggled behavior: When the modifier key is pressed and released on its own it first toggles into a latched state. When latched, the modifier will apply to next character key that is pressed and will then reset itself to the initial state. If the modifier is already latched and the modifier key is pressed and release on its own again, then it toggles into a locked state. When locked, the modifier will apply to all subsequent character keys that are pressed until unlocked by pressing the modifier key on its own one more time to reset it to the initial state. Toggled behavior is useful for small profile keyboards designed for thumb typing.

This function currently returns `https://developer.android.com/reference/android/view/KeyCharacterMap#MODIFIER_BEHAVIOR_CHORDED` when the `https://developer.android.com/reference/android/view/KeyCharacterMap#getKeyboardType()` is `https://developer.android.com/reference/android/view/KeyCharacterMap#FULL` or `https://developer.android.com/reference/android/view/KeyCharacterMap#SPECIAL_FUNCTION` and `https://developer.android.com/reference/android/view/KeyCharacterMap#MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED` otherwise. In the future, the function may also take into account global keyboard accessibility settings, other user preferences, or new device capabilities.

<br />

<br />

| Returns ||
|---|---|
| `int` | The modifier behavior for this keyboard. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/KeyCharacterMap#MODIFIER_BEHAVIOR_CHORDED`
- `https://developer.android.com/reference/android/view/KeyCharacterMap#MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED`

### getNumber

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

```
public char getNumber (int keyCode)
```

Gets the number or symbol associated with the key.

The character value is returned, not the numeric value. If the key is not a number, but is a symbol, the symbol is retuned.

This method is intended to to support dial pads and other numeric or symbolic entry on keyboards where certain keys serve dual function as alphabetic and symbolic keys. This method returns the number or symbol associated with the key independent of whether the user has pressed the required modifier.

For example, on one particular keyboard the keys on the top QWERTY row generate numbers when ALT is pressed such that ALT-Q maps to '1'. So for that keyboard when `https://developer.android.com/reference/android/view/KeyCharacterMap#getNumber(int)` is called with `https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_Q` it returns '1' so that the user can type numbers without pressing ALT when it makes sense.

<br />

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The key code. <br /> |

| Returns ||
|---|---|
| `char` | The associated numeric or symbolic character, or 0 if none. <br /> |

### isPrintingKey

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

```
public boolean isPrintingKey (int keyCode)
```

Returns true if the specified key produces a glyph.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The key code. <br /> |

| Returns ||
|---|---|
| `boolean` | True if the key is a printing key. <br /> |

### load

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

```
public static KeyCharacterMap load (int deviceId)
```

Loads the key character maps for the keyboard with the specified device id.

<br />

| Parameters ||
|---|---|
| `deviceId` | `int`: The device id of the keyboard. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/KeyCharacterMap` | The associated key character map. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/view/KeyCharacterMap.UnavailableException` | if the key character map could not be loaded because it was malformed or the default key character map is missing from the system. |

### writeToParcel

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

```
public void writeToParcel (Parcel out, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `out` | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |

## Protected methods

### finalize

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

```
protected void finalize ()
```

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the `finalize` method to dispose of system resources or to perform other cleanup.

The general contract of `finalize` is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The `finalize` method may take any action, including making this object available again to other threads; the usual purpose of `finalize`, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The `finalize` method of class `Object` performs no special action; it simply returns normally. Subclasses of `Object` may override this definition.

The Java programming language does not guarantee which thread will invoke the `finalize` method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the `finalize` method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The `finalize` method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the `finalize` method causes the finalization of this object to be halted, but is otherwise ignored.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Throwable` |   |