Struct KeyEvent

Source
pub struct KeyEvent { /* private fields */ }
Expand description

A key event.

For general discussion of key events in Android, see the relevant javadoc.

Implementations§

Source§

impl KeyEvent

Source

pub unsafe fn from_ptr(ptr: NonNull<AInputEvent>) -> Self

Constructs a KeyEvent from a pointer to a native AInputEvent

By calling this method, you assert that the pointer is a valid, non-null pointer to an AInputEvent, and that that AInputEvent is an AKeyEvent.

Source

pub fn ptr(&self) -> NonNull<AInputEvent>

Returns a pointer to the native AInputEvent

Source

pub fn action(&self) -> KeyAction

Returns the key action represented by this event.

See the NDK docs

Source

pub fn source(&self) -> Source

Get the source of the event.

See the NDK docs

Source

pub fn device_id(&self) -> i32

Get the device id associated with the event.

See the NDK docs

Source

pub fn down_time(&self) -> i64

Returns the last time the key was pressed. This is on the scale of java.lang.System.nanoTime(), which has nanosecond precision, but no defined start time.

See the NDK docs

Source

pub fn event_time(&self) -> i64

Returns the time this event occured. This is on the scale of java.lang.System.nanoTime(), which has nanosecond precision, but no defined start time.

See the NDK docs

Source

pub fn key_code(&self) -> Keycode

Returns the keycode associated with this key event

See the NDK docs

Source

pub fn repeat_count(&self) -> i32

Returns the number of repeats of a key.

See the NDK docs

Source

pub fn scan_code(&self) -> i32

Returns the hardware keycode of a key. This varies from device to device.

See the NDK docs

Source§

impl KeyEvent

Source

pub fn flags(&self) -> KeyEventFlags

Flags associated with KeyEvent.

See the NDK docs

Source

pub fn meta_state(&self) -> MetaState

Returns the state of the modifiers during this key event, represented by a bitmask.

See the NDK docs

Trait Implementations§

Source§

impl Debug for KeyEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<'a, T> Desc<'a, T> for T

Source§

fn lookup(self, _: &JNIEnv<'a>) -> Result<T, Error>

Look up the concrete type from the JVM.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.