KeyEvent KeyEvent Class

Definition

Object used to report key and button events.

[Android.Runtime.Register("android/view/KeyEvent", ApiSince=1, DoNotGenerateAcw=true)]
public class KeyEvent : Android.Views.InputEvent, IDisposable
type KeyEvent = class
    inherit InputEvent
    interface IParcelable
    interface IJavaObject
    interface IDisposable
Inheritance
Derived
Attributes
Implements

Remarks

Android platform documentation

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32) KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32)

Create a new key event.

KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates) KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates)

Create a new key event.

KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates, Int32, Int32) KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates, Int32, Int32)

Create a new key event.

KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates, Int32, Int32, KeyEventFlags) KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates, Int32, Int32, KeyEventFlags)

Create a new key event.

KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates, Int32, Int32, KeyEventFlags, InputSourceType) KeyEvent(Int64, Int64, KeyEventActions, Keycode, Int32, MetaKeyStates, Int32, Int32, KeyEventFlags, InputSourceType)

Create a new key event.

KeyEvent(Int64, String, Int32, KeyEventFlags) KeyEvent(Int64, String, Int32, KeyEventFlags)

Create a new key event for a string of characters.

KeyEvent(IntPtr, JniHandleOwnership) KeyEvent(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

KeyEvent(KeyEvent) KeyEvent(KeyEvent)

Make an exact copy of an existing key event.

KeyEvent(KeyEvent, Int64, Int32) KeyEvent(KeyEvent, Int64, Int32)

Copy an existing key event, modifying its time and repeat count.

KeyEvent(KeyEventActions, Keycode) KeyEvent(KeyEventActions, Keycode)

Create a new key event.

Fields

MaxKeycode MaxKeycode

Properties

Action Action

Retrieve the action of this key event.

Characters Characters

For the special case of a Android.Views.KeyEvent.ACTION_MULTIPLE event with key code of Unknown, this is a raw string of characters associated with the event.

Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
Creator Creator
Device Device

Gets the device that this event came from.

(Inherited from InputEvent)
DeviceId DeviceId

Gets the id for the device that this event came from.

DisplayLabel DisplayLabel

Gets the primary character for this key.

DownTime DownTime

Retrieve the time of the most recent key down event, in the UptimeMillis() time base.

EventTime EventTime

Retrieve the time this event occurred, in the UptimeMillis() time base.

Flags Flags

Returns the flags for this key event.

Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
HasNoModifiers HasNoModifiers

Returns true if no modifier keys are pressed.

IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
IsAltPressed IsAltPressed
IsCanceled IsCanceled

For Android.Views.KeyEvent.ACTION_UP events, indicates that the event has been canceled as per Android.Views.KeyEvent.FLAG_CANCELED.

IsCapsLockOn IsCapsLockOn
IsCtrlPressed IsCtrlPressed
IsFunctionPressed IsFunctionPressed
IsLongPress IsLongPress

For Android.Views.KeyEvent.ACTION_DOWN events, indicates that the event has been canceled as per Android.Views.KeyEvent.FLAG_LONG_PRESS.

IsMetaPressed IsMetaPressed
IsNumLockOn IsNumLockOn
IsPrintingKey IsPrintingKey

Returns true if this key produces a glyph.

IsScrollLockOn IsScrollLockOn
IsShiftPressed IsShiftPressed
IsSymPressed IsSymPressed
IsSystem IsSystem

Is this a system key? System keys can not be used for menu shortcuts.

IsTracking IsTracking

For Android.Views.KeyEvent.ACTION_UP events, indicates that the event is still being tracked from its initial down event as per Android.Views.KeyEvent.FLAG_TRACKING.

JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
KeyCharacterMap KeyCharacterMap

Gets the KeyCharacterMap associated with the keyboard device.

KeyCode KeyCode

Retrieve the key code of the key event.

MaxKeyCode MaxKeyCode

Returns the maximum keycode.

MetaState MetaState
ModifierMetaStateMask ModifierMetaStateMask

Gets a mask that includes all valid modifier key meta state bits.

Modifiers Modifiers

Returns the state of the modifier keys.

Number Number

Gets the number or symbol associated with the key.

PeerReference PeerReference Inherited from Object
RepeatCount RepeatCount

Retrieve the repeat count of the event.

ScanCode ScanCode

Retrieve the hardware key id of this key event.

Source Source

Gets the source of the event.

ThresholdClass ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

UnicodeChar UnicodeChar

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

Methods

ChangeAction(KeyEvent, KeyEventActions) ChangeAction(KeyEvent, KeyEventActions)

Create a new key event that is the same as the given one, but whose action is replaced with the given value.

ChangeFlags(KeyEvent, KeyEventFlags) ChangeFlags(KeyEvent, KeyEventFlags)

Create a new key event that is the same as the given one, but whose flags are replaced with the given value.

ChangeTimeRepeat(KeyEvent, Int64, Int32) ChangeTimeRepeat(KeyEvent, Int64, Int32)

Create a new key event that is the same as the given one, but whose event time and repeat count are replaced with the given value.

ChangeTimeRepeat(KeyEvent, Int64, Int32, KeyEventFlags) ChangeTimeRepeat(KeyEvent, Int64, Int32, KeyEventFlags)

Create a new key event that is the same as the given one, but whose event time and repeat count are replaced with the given value.

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
DescribeContents() DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

(Inherited from InputEvent)
Dispatch(KeyEvent+ICallback) Dispatch(KeyEvent+ICallback)
Dispatch(KeyEvent+ICallback, KeyEvent+DispatcherState, Object) Dispatch(KeyEvent+ICallback, KeyEvent+DispatcherState, Object)

KeyEvent Callback

Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
GetDeadChar(Int32, Int32) GetDeadChar(Int32, Int32)

Get the character that is produced by putting accent on the character c.

GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
GetKeyData(KeyCharacterMap+KeyData) GetKeyData(KeyCharacterMap+KeyData)

Get the character conversion data for a given key code.

GetMatch(Char[]) GetMatch(Char[])

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

GetMatch(Char[], Int32) GetMatch(Char[], Int32)
GetMatch(Char[], MetaKeyStates) GetMatch(Char[], MetaKeyStates)

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

GetUnicodeChar(Int32) GetUnicodeChar(Int32)
GetUnicodeChar(MetaKeyStates) GetUnicodeChar(MetaKeyStates)

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

HasModifiers(MetaKeyStates) HasModifiers(MetaKeyStates)

Returns true if only the specified modifiers keys are pressed.

IsFromSource(InputSourceType) IsFromSource(InputSourceType)

Determines whether the event is from the given source.

(Inherited from InputEvent)
IsGamepadButton(Keycode) IsGamepadButton(Keycode)

Returns true if the specified keycode is a gamepad button.

IsModifierKey(Keycode) IsModifierKey(Keycode)

Returns true if this key code is a modifier key.

JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
KeyCodeFromString(String) KeyCodeFromString(String)

Gets a keycode by its symbolic name such as "KEYCODE_A" or an equivalent numeric constant such as "1001".

KeyCodeToString(Keycode) KeyCodeToString(Keycode)

Returns a string that represents the symbolic name of the specified keycode such as "KEYCODE_A", "KEYCODE_DPAD_UP", or an equivalent numeric constant such as "1001" if unknown.

MetaStateHasModifiers(MetaKeyStates, MetaKeyStates) MetaStateHasModifiers(MetaKeyStates, MetaKeyStates)

Returns true if only the specified modifier keys are pressed according to the specified meta state.

MetaStateHasNoModifiers(MetaKeyStates) MetaStateHasNoModifiers(MetaKeyStates)

Returns true if no modifiers keys are pressed according to the specified meta state.

NormalizeMetaState(MetaKeyStates) NormalizeMetaState(MetaKeyStates)

Normalizes the specified meta state.

Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetSource(InputSourceType) SetSource(InputSourceType)

Modifies the source of the event.

StartTracking() StartTracking()

Call this during OnKeyDown(Keycode, KeyEvent) to have the system track the key through its final up (possibly including a long press).

ToArray<T>() ToArray<T>() Inherited from Object
ToString() ToString()

Returns a string containing a concise, human-readable description of this object.

(Inherited from Object)
UnregisterFromRuntime() UnregisterFromRuntime() Inherited from Object
Wait() Wait()

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags) WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

IJavaObjectEx.ToLocalJniHandle() IJavaObjectEx.ToLocalJniHandle() Inherited from Object
IJavaPeerable.Disposed() IJavaPeerable.Disposed() Inherited from Object
IJavaPeerable.DisposeUnlessReferenced() IJavaPeerable.DisposeUnlessReferenced() Inherited from Object
IJavaPeerable.Finalized() IJavaPeerable.Finalized() Inherited from Object
IJavaPeerable.SetJniIdentityHashCode(Int32) IJavaPeerable.SetJniIdentityHashCode(Int32) Inherited from Object
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) Inherited from Object
IJavaPeerable.SetPeerReference(JniObjectReference) IJavaPeerable.SetPeerReference(JniObjectReference) Inherited from Object

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to