# MetaKeyKeyListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Constants](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#constants)\|[Ctors](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#pubctors)\|[Methods](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#inhmethods)  

# MetaKeyKeyListener

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/text/method/MetaKeyKeyListener "View this page in Kotlin")\|Java

`
public


abstract
class
MetaKeyKeyListener
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|----------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.text.method.MetaKeyKeyListener |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [BaseKeyListener](https://developer.android.com/reference/android/text/method/BaseKeyListener) |------------------------------------------------------------------------------------------------|----------------------------------------| | [BaseKeyListener](https://developer.android.com/reference/android/text/method/BaseKeyListener) | Abstract base class for key listeners. | |

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [DateKeyListener](https://developer.android.com/reference/android/text/method/DateKeyListener),[DateTimeKeyListener](https://developer.android.com/reference/android/text/method/DateTimeKeyListener),[DialerKeyListener](https://developer.android.com/reference/android/text/method/DialerKeyListener),[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener),[MultiTapKeyListener](https://developer.android.com/reference/android/text/method/MultiTapKeyListener),[NumberKeyListener](https://developer.android.com/reference/android/text/method/NumberKeyListener),[QwertyKeyListener](https://developer.android.com/reference/android/text/method/QwertyKeyListener),[TextKeyListener](https://developer.android.com/reference/android/text/method/TextKeyListener),[TimeKeyListener](https://developer.android.com/reference/android/text/method/TimeKeyListener) |--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [DateKeyListener](https://developer.android.com/reference/android/text/method/DateKeyListener)         | For entering dates in a text field.                                                                                                                                                                           | | [DateTimeKeyListener](https://developer.android.com/reference/android/text/method/DateTimeKeyListener) | For entering dates and times in the same text field.                                                                                                                                                          | | [DialerKeyListener](https://developer.android.com/reference/android/text/method/DialerKeyListener)     | For dialing-only text entry <br /> As for all implementations of[KeyListener](https://developer.android.com/reference/android/text/method/KeyListener), this class is only concerned with hardware keyboards. | | [DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener)     | For digits-only text entry <br /> As for all implementations of[KeyListener](https://developer.android.com/reference/android/text/method/KeyListener), this class is only concerned with hardware keyboards.  | | [MultiTapKeyListener](https://developer.android.com/reference/android/text/method/MultiTapKeyListener) | This is the standard key listener for alphabetic input on 12-key keyboards.                                                                                                                                   | | [NumberKeyListener](https://developer.android.com/reference/android/text/method/NumberKeyListener)     | For numeric text entry <br /> As for all implementations of[KeyListener](https://developer.android.com/reference/android/text/method/KeyListener), this class is only concerned with hardware keyboards.      | | [QwertyKeyListener](https://developer.android.com/reference/android/text/method/QwertyKeyListener)     | This is the standard key listener for alphabetic input on qwerty keyboards.                                                                                                                                   | | [TextKeyListener](https://developer.android.com/reference/android/text/method/TextKeyListener)         | This is the key listener for typing normal text.                                                                                                                                                              | | [TimeKeyListener](https://developer.android.com/reference/android/text/method/TimeKeyListener)         | For entering times in a text field.                                                                                                                                                                           | |

<br />

*** ** * ** ***

This base class encapsulates the behavior for tracking the state of meta keys such as SHIFT, ALT and SYM as well as the pseudo-meta state of selecting text.

Key listeners that care about meta state should inherit from this class; you should not instantiate this class directly in a client.

This class provides two mechanisms for tracking meta state that can be used together or independently.

- Methods such as[handleKeyDown(long, int, android.view.KeyEvent)](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#handleKeyDown(long,%20int,%20android.view.KeyEvent))and[getMetaState(long)](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(long))operate on a meta key state bit mask.
- Methods such as[onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#onKeyDown(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))and[getMetaState(java.lang.CharSequence, int)](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence,%20int))operate on meta key state flags stored as spans in an[Editable](https://developer.android.com/reference/android/text/Editable)text buffer. The spans only describe the current meta key state of the text editor; they do not carry any positional information.

The behavior of this class varies according to the keyboard capabilities described by the[KeyCharacterMap](https://developer.android.com/reference/android/view/KeyCharacterMap)of the keyboard device such as the[key modifier behavior](https://developer.android.com/reference/android/view/KeyCharacterMap#getModifierBehavior()).

[MetaKeyKeyListener](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener)implements chorded and toggled key modifiers. When key modifiers are toggled into a latched or locked state, the state of the modifier is stored in the[Editable](https://developer.android.com/reference/android/text/Editable)text buffer or in a meta state integer managed by the client. These latched or locked modifiers should be considered to be held**in addition to** those that the keyboard already reported as being pressed in[KeyEvent.getMetaState()](https://developer.android.com/reference/android/view/KeyEvent#getMetaState()). In other words, the[MetaKeyKeyListener](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener)augments the meta state provided by the keyboard; it does not replace it. This distinction is important to ensure that meta keys not handled by[MetaKeyKeyListener](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener)such as[KeyEvent.KEYCODE_CAPS_LOCK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_CAPS_LOCK)or[KeyEvent.KEYCODE_NUM_LOCK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_NUM_LOCK)are taken into consideration.

To ensure correct meta key behavior, the following pattern should be used when mapping key codes to characters:
`
private char getUnicodeChar(TextKeyListener listener, KeyEvent event, Editable textBuffer) {
// Use the combined meta states from the event and the key listener.
int metaState = event.getMetaState() | listener.getMetaState(textBuffer);
return event.getUnicodeChar(metaState);
}
`

<br />

## Summary

|                                                                                      ### Constants                                                                                      ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [META_ALT_LOCKED](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_ALT_LOCKED) Flag that indicates that the ALT key is locked.                |
| `int` | [META_ALT_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_ALT_ON) Flag that indicates that the ALT key is on.                            |
| `int` | [META_CAP_LOCKED](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_CAP_LOCKED) Flag that indicates that the SHIFT key is locked in CAPS mode. |
| `int` | [META_SHIFT_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SHIFT_ON) Flag that indicates that the SHIFT key is on.                      |
| `int` | [META_SYM_LOCKED](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SYM_LOCKED) Flag that indicates that the SYM key is locked.                |
| `int` | [META_SYM_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SYM_ON) Flag that indicates that the SYM key is on.                            |

|                                                       ### Public constructors                                                        ||
|-----------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[MetaKeyKeyListener](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#MetaKeyKeyListener())`() ` |

|                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                               ||
|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static void`      | ` `[adjustMetaAfterKeypress](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#adjustMetaAfterKeypress(android.text.Spannable))`(`[Spannable](https://developer.android.com/reference/android/text/Spannable)` content) ` Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released).                                                |
| ` static long`      | ` `[adjustMetaAfterKeypress](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#adjustMetaAfterKeypress(long))`(long state) ` Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released).                                                                                                                                             |
| ` static void`      | ` `[clearMetaKeyState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(android.text.Editable,%20int))`(`[Editable](https://developer.android.com/reference/android/text/Editable)` content, int states) `                                                                                                                                                                                                                               |
| ` long`             | ` `[clearMetaKeyState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(long,%20int))`(long state, int which) ` Clears the state of the specified meta key if it is locked.                                                                                                                                                                                                                                                              |
| ` void`             | ` `[clearMetaKeyState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(android.view.View,%20android.text.Editable,%20int))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int states) `                                                                                                                                |
| ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text) ` Gets the state of the meta keys.                                                                                                                                                                                                                        |
| ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence,%20int))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, int meta) ` Gets the state of a particular meta key.                                                                                                                                                                                               |
| ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(long))`(long state) ` Gets the state of the meta keys.                                                                                                                                                                                                                                                                                                                     |
| ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence,%20android.view.KeyEvent))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Gets the state of the meta keys for a specific key event.                                                                                   |
| ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(long,%20int))`(long state, int meta) ` Gets the state of a particular meta key.                                                                                                                                                                                                                                                                                            |
| ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence,%20int,%20android.view.KeyEvent))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, int meta, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Gets the state of a particular meta key to use with a particular key event.                                                |
| ` static long`      | ` `[handleKeyDown](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#handleKeyDown(long,%20int,%20android.view.KeyEvent))`(long state, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles presses of the meta keys.                                                                                                                                                                                  |
| ` static long`      | ` `[handleKeyUp](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#handleKeyUp(long,%20int,%20android.view.KeyEvent))`(long state, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles release of the meta keys.                                                                                                                                                                                      |
| ` static boolean`   | ` `[isMetaTracker](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#isMetaTracker(java.lang.CharSequence,%20java.lang.Object))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Object](https://developer.android.com/reference/java/lang/Object)` what) ` Returns true if this object is one that this class would use to keep track of any meta state in the specified text.                                    |
| ` static boolean`   | ` `[isSelectingMetaTracker](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#isSelectingMetaTracker(java.lang.CharSequence,%20java.lang.Object))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Object](https://developer.android.com/reference/java/lang/Object)` what) ` Returns true if this object is one that this class would use to keep track of the selecting meta state in the specified text.        |
| ` boolean`          | ` `[onKeyDown](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#onKeyDown(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles presses of the meta keys. |
| ` boolean`          | ` `[onKeyUp](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#onKeyUp(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles release of the meta keys.     |
| ` static long`      | ` `[resetLockedMeta](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#resetLockedMeta(long))`(long state) ` Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key.                                                                                                                                                                                                                               |
| ` static void`      | ` `[resetMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#resetMetaState(android.text.Spannable))`(`[Spannable](https://developer.android.com/reference/android/text/Spannable)` text) ` Resets all meta state to inactive.                                                                                                                                                                                                                     |

|                                                                                                                                                                          ### Protected methods                                                                                                                                                                          ||
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static void` | ` `[resetLockedMeta](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#resetLockedMeta(android.text.Spannable))`(`[Spannable](https://developer.android.com/reference/android/text/Spannable)` content) ` Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Constants

### META_ALT_LOCKED

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

```
public static final int META_ALT_LOCKED
```

Flag that indicates that the ALT key is locked.

<br />

Constant Value: 512 (0x00000200)  

### META_ALT_ON

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

```
public static final int META_ALT_ON
```

Flag that indicates that the ALT key is on. Value equals[KeyEvent.META_ALT_ON](https://developer.android.com/reference/android/view/KeyEvent#META_ALT_ON).

<br />

Constant Value: 2 (0x00000002)  

### META_CAP_LOCKED

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

```
public static final int META_CAP_LOCKED
```

Flag that indicates that the SHIFT key is locked in CAPS mode.

<br />

Constant Value: 256 (0x00000100)  

### META_SHIFT_ON

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

```
public static final int META_SHIFT_ON
```

Flag that indicates that the SHIFT key is on. Value equals[KeyEvent.META_SHIFT_ON](https://developer.android.com/reference/android/view/KeyEvent#META_SHIFT_ON).

<br />

Constant Value: 1 (0x00000001)  

### META_SYM_LOCKED

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

```
public static final int META_SYM_LOCKED
```

Flag that indicates that the SYM key is locked.

<br />

Constant Value: 1024 (0x00000400)  

### META_SYM_ON

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

```
public static final int META_SYM_ON
```

Flag that indicates that the SYM key is on. Value equals[KeyEvent.META_SYM_ON](https://developer.android.com/reference/android/view/KeyEvent#META_SYM_ON).

<br />

Constant Value: 4 (0x00000004)

## Public constructors

### MetaKeyKeyListener

```
public MetaKeyKeyListener ()
```

<br />

<br />

## Public methods

### adjustMetaAfterKeypress

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

```
public static void adjustMetaAfterKeypress (Spannable content)
```

Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released).

<br />

|          Parameters           ||
|-----------|--------------------|
| `content` | `Spannable` <br /> |

### adjustMetaAfterKeypress

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

```
public static long adjustMetaAfterKeypress (long state)
```

Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released). Takes the current state, returns the new state.

<br />

|       Parameters       ||
|---------|---------------|
| `state` | `long` <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

### clearMetaKeyState

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

```
public static void clearMetaKeyState (Editable content, 
                int states)
```

<br />

<br />

|          Parameters          ||
|-----------|-------------------|
| `content` | `Editable` <br /> |
| `states`  | `int` <br />      |

### clearMetaKeyState

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

```
public long clearMetaKeyState (long state, 
                int which)
```

Clears the state of the specified meta key if it is locked.

<br />

|                                                                                                                                                                                              Parameters                                                                                                                                                                                               ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state` | `long`: the meta key state <br />                                                                                                                                                                                                                                                                                                                                                            |
| `which` | `int`: meta keys to clear, may be a combination of[META_SHIFT_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SHIFT_ON),[META_ALT_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_ALT_ON)or[META_SYM_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SYM_ON). <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

### clearMetaKeyState

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

```
public void clearMetaKeyState (View view, 
                Editable content, 
                int states)
```

<br />

<br />

|          Parameters          ||
|-----------|-------------------|
| `view`    | `View` <br />     |
| `content` | `Editable` <br /> |
| `states`  | `int` <br />      |

### getMetaState

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

```
public static final int getMetaState (CharSequence text)
```

Gets the state of the meta keys.

<br />

|                                        Parameters                                        ||
|--------|----------------------------------------------------------------------------------|
| `text` | `CharSequence`: the buffer in which the meta key would have been pressed. <br /> |

|                                            Returns                                             ||
|-------|-----------------------------------------------------------------------------------------|
| `int` | an integer in which each bit set to one represents a pressed or locked meta key. <br /> |

### getMetaState

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

```
public static final int getMetaState (CharSequence text, 
                int meta)
```

Gets the state of a particular meta key.

<br />

|                                        Parameters                                        ||
|--------|----------------------------------------------------------------------------------|
| `text` | `CharSequence`: the buffer in which the meta key would have been pressed. <br /> |
| `meta` | `int`: META_SHIFT_ON, META_ALT_ON, META_SYM_ON <br />                            |

|                        Returns                         ||
|-------|-------------------------------------------------|
| `int` | 0 if inactive, 1 if active, 2 if locked. <br /> |

### getMetaState

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

```
public static final int getMetaState (long state)
```

Gets the state of the meta keys.

<br />

|                      Parameters                      ||
|---------|---------------------------------------------|
| `state` | `long`: the current meta state bits. <br /> |

|                                            Returns                                             ||
|-------|-----------------------------------------------------------------------------------------|
| `int` | an integer in which each bit set to one represents a pressed or locked meta key. <br /> |

### getMetaState

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

```
public static final int getMetaState (CharSequence text, 
                KeyEvent event)
```

Gets the state of the meta keys for a specific key event. For input devices that use toggled key modifiers, the \`toggled' state is stored into the text buffer. This method retrieves the meta state for this event, accounting for the stored state. If the event has been created by a device that does not support toggled key modifiers, like a virtual device for example, the stored state is ignored.

<br />

|                                        Parameters                                         ||
|---------|----------------------------------------------------------------------------------|
| `text`  | `CharSequence`: the buffer in which the meta key would have been pressed. <br /> |
| `event` | `KeyEvent`: the event for which to evaluate the meta state. <br />               |

|                                            Returns                                             ||
|-------|-----------------------------------------------------------------------------------------|
| `int` | an integer in which each bit set to one represents a pressed or locked meta key. <br /> |

### getMetaState

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

```
public static final int getMetaState (long state, 
                int meta)
```

Gets the state of a particular meta key.

<br />

|                            Parameters                             ||
|---------|----------------------------------------------------------|
| `state` | `long`: the current state bits. <br />                   |
| `meta`  | `int`: META_SHIFT_ON, META_ALT_ON, or META_SYM_ON <br /> |

|                        Returns                         ||
|-------|-------------------------------------------------|
| `int` | 0 if inactive, 1 if active, 2 if locked. <br /> |

### getMetaState

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

```
public static final int getMetaState (CharSequence text, 
                int meta, 
                KeyEvent event)
```

Gets the state of a particular meta key to use with a particular key event. If the key event has been created by a device that does not support toggled key modifiers, like a virtual keyboard for example, only the meta state in the key event is considered.

<br />

|                                        Parameters                                         ||
|---------|----------------------------------------------------------------------------------|
| `text`  | `CharSequence`: the buffer in which the meta key would have been pressed. <br /> |
| `meta`  | `int`: META_SHIFT_ON, META_ALT_ON, META_SYM_ON <br />                            |
| `event` | `KeyEvent`: the event for which to evaluate the meta state. <br />               |

|                        Returns                         ||
|-------|-------------------------------------------------|
| `int` | 0 if inactive, 1 if active, 2 if locked. <br /> |

### handleKeyDown

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

```
public static long handleKeyDown (long state, 
                int keyCode, 
                KeyEvent event)
```

Handles presses of the meta keys.

<br />

|          Parameters          ||
|-----------|-------------------|
| `state`   | `long` <br />     |
| `keyCode` | `int` <br />      |
| `event`   | `KeyEvent` <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

### handleKeyUp

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

```
public static long handleKeyUp (long state, 
                int keyCode, 
                KeyEvent event)
```

Handles release of the meta keys.

<br />

|          Parameters          ||
|-----------|-------------------|
| `state`   | `long` <br />     |
| `keyCode` | `int` <br />      |
| `event`   | `KeyEvent` <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

### isMetaTracker

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

```
public static boolean isMetaTracker (CharSequence text, 
                Object what)
```

Returns true if this object is one that this class would use to keep track of any meta state in the specified text.

<br />

|          Parameters           ||
|--------|-----------------------|
| `text` | `CharSequence` <br /> |
| `what` | `Object` <br />       |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isSelectingMetaTracker

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

```
public static boolean isSelectingMetaTracker (CharSequence text, 
                Object what)
```

Returns true if this object is one that this class would use to keep track of the selecting meta state in the specified text.

<br />

|          Parameters           ||
|--------|-----------------------|
| `text` | `CharSequence` <br /> |
| `what` | `Object` <br />       |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### onKeyDown

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

```
public boolean onKeyDown (View view, 
                Editable content, 
                int keyCode, 
                KeyEvent event)
```

Handles presses of the meta keys.

<br />

|          Parameters          ||
|-----------|-------------------|
| `view`    | `View` <br />     |
| `content` | `Editable` <br /> |
| `keyCode` | `int` <br />      |
| `event`   | `KeyEvent` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### onKeyUp

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

```
public boolean onKeyUp (View view, 
                Editable content, 
                int keyCode, 
                KeyEvent event)
```

Handles release of the meta keys.

<br />

|          Parameters          ||
|-----------|-------------------|
| `view`    | `View` <br />     |
| `content` | `Editable` <br /> |
| `keyCode` | `int` <br />      |
| `event`   | `KeyEvent` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### resetLockedMeta

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

```
public static long resetLockedMeta (long state)
```

Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key.

<br />

|       Parameters       ||
|---------|---------------|
| `state` | `long` <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

### resetMetaState

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

```
public static void resetMetaState (Spannable text)
```

Resets all meta state to inactive.

<br />

|         Parameters         ||
|--------|--------------------|
| `text` | `Spannable` <br /> |

## Protected methods

### resetLockedMeta

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

```
protected static void resetLockedMeta (Spannable content)
```

Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key.

<br />

|          Parameters           ||
|-----------|--------------------|
| `content` | `Spannable` <br /> |