KeyEvent Class

Definition

Object used to report key and button events.

[Android.Runtime.Register("android/view/KeyEvent", DoNotGenerateAcw=true)]
public class KeyEvent : Android.Views.InputEvent, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/view/KeyEvent", DoNotGenerateAcw=true)>]
type KeyEvent = class
    inherit InputEvent
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Attributes
Implements

Remarks

Java documentation for android.view.KeyEvent.

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)

Create a new key event.

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

Create a new key event.

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

Create a new key event.

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)

Create a new key event.

KeyEvent(Int64, String, Int32, KeyEventFlags)

Create a new key event for a string of characters.

KeyEvent(IntPtr, JniHandleOwnership)

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

KeyEvent(KeyEvent)

Make an exact copy of an existing key event.

KeyEvent(KeyEvent, Int64, Int32)
Obsolete.

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

KeyEvent(KeyEventActions, Keycode)

Create a new key event.

Fields

MaxKeycode

Properties

Action

Retrieve the action of this key event.

Characters
Obsolete.

For the special case of a #ACTION_MULTIPLE event with key code of #KEYCODE_UNKNOWN, this is a raw string of characters associated with the event.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Device

Gets the device that this event came from.

(Inherited from InputEvent)
DeviceId

[TODO: @inheritDoc]

DisplayLabel

Gets the primary character for this key.

DownTime

Retrieve the time of the most recent key down event, in the android.os.SystemClock#uptimeMillis time base.

EventTime

Retrieve the time this event occurred, in the android.os.SystemClock#uptimeMillis time base.

Flags

Returns the flags for this key event.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
HasNoModifiers

Returns true if no modifier keys are pressed.

IsAltPressed

Returns the pressed state of the ALT meta key.

IsCanceled

For #ACTION_UP events, indicates that the event has been canceled as per #FLAG_CANCELED.

IsCapsLockOn

Returns the locked state of the CAPS LOCK meta key.

IsCtrlPressed

Returns the pressed state of the CTRL meta key.

IsFunctionPressed

Returns the pressed state of the FUNCTION meta key.

IsLongPress

For #ACTION_DOWN events, indicates that the event has been canceled as per #FLAG_LONG_PRESS.

IsMetaPressed

Returns the pressed state of the META meta key.

IsNumLockOn

Returns the locked state of the NUM LOCK meta key.

IsPrintingKey

Returns true if this key produces a glyph.

IsScrollLockOn

Returns the locked state of the SCROLL LOCK meta key.

IsShiftPressed

Returns the pressed state of the SHIFT meta key.

IsSymPressed

Returns the pressed state of the SYM meta key.

IsSystem

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

IsTracking

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

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
KeyCharacterMap

Gets the KeyCharacterMap associated with the keyboard device.

KeyCode

Retrieve the key code of the key event.

MaxKeyCode

Returns the maximum keycode.

MetaState

Returns the state of the meta keys.

ModifierMetaStateMask

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

Modifiers

Returns the state of the modifier keys.

Number

Gets the number or symbol associated with the key.

PeerReference (Inherited from Object)
RepeatCount

Retrieve the repeat count of the event.

ScanCode

Retrieve the hardware key id of this key event.

Source

[TODO: @inheritDoc]

ThresholdClass

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

ThresholdType

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

UnicodeChar

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

Methods

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)

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)

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)

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()

Creates and returns a copy of this object.

(Inherited from Object)
DescribeContents()

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

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

Deliver this key event to a KeyEvent Callback interface.

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

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

(Inherited from Object)
GetDeadChar(Int32, Int32)

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

GetHashCode()

Returns a hash code value for the object.

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

Get the character conversion data for a given key code.

GetMatch(Char[])

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

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

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

GetUnicodeChar(Int32)
GetUnicodeChar(MetaKeyStates)

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

HasModifiers(MetaKeyStates)

Returns true if only the specified modifiers keys are pressed.

IsFromSource(InputSourceType)

Determines whether the event is from the given source.

(Inherited from InputEvent)
IsGamepadButton(Keycode)

Returns true if the specified keycode is a gamepad button.

IsMediaSessionKey(Int32)

Returns whether this key will be sent to the android.media.session.MediaSession.Callback if not handled.

IsModifierKey(Keycode)

Returns true if this key code is a modifier key.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
KeyCodeFromString(String)

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

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)

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

MetaStateHasNoModifiers(MetaKeyStates)

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

NormalizeMetaState(MetaKeyStates)

Normalizes the specified meta state.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetSource(InputSourceType)

[TODO: @inheritDoc]

StartTracking()

Call this during Callback#onKeyDown to have the system track the key through its final up (possibly including a long press).

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

Returns a string representation of the object.

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

Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until either another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object, or a specified amount of time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

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

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to