pub struct KeyEvent { /* private fields */ }
Expand description
A key event
Wraps an AInputEvent *
of the ffi::AINPUT_EVENT_TYPE_KEY
type.
For general discussion of key events in Android, see the relevant javadoc.
Implementations
sourceimpl KeyEvent
impl KeyEvent
sourcepub unsafe fn from_ptr(ptr: NonNull<AInputEvent>) -> Self
pub unsafe fn from_ptr(ptr: NonNull<AInputEvent>) -> Self
Constructs a KeyEvent from a pointer to a native ffi::AInputEvent
Safety
By calling this method, you assert that the pointer is a valid, non-null pointer to an
ffi::AInputEvent
, and that ffi::AInputEvent
is an AKeyEvent
.
sourcepub fn ptr(&self) -> NonNull<AInputEvent>
pub fn ptr(&self) -> NonNull<AInputEvent>
Returns a pointer to the native ffi::AInputEvent
sourcepub fn action(&self) -> KeyAction
pub fn action(&self) -> KeyAction
Returns the key action represented by this event.
See the NDK docs
sourcepub fn source(&self) -> Source
pub fn source(&self) -> Source
Get the source of the event.
See the NDK docs
sourcepub fn device_id(&self) -> i32
pub fn device_id(&self) -> i32
Get the device id associated with the event.
See the NDK docs
sourcepub fn down_time(&self) -> i64
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
sourcepub fn event_time(&self) -> i64
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
sourcepub fn key_code(&self) -> Keycode
pub fn key_code(&self) -> Keycode
Returns the keycode associated with this key event
See the NDK docs
sourcepub fn repeat_count(&self) -> i32
pub fn repeat_count(&self) -> i32
Returns the number of repeats of a key.
See the NDK docs
sourcepub fn scan_code(&self) -> i32
pub fn scan_code(&self) -> i32
Returns the hardware keycode of a key. This varies from device to device.
See the NDK docs
sourceimpl KeyEvent
impl KeyEvent
sourcepub fn flags(&self) -> KeyEventFlags
pub fn flags(&self) -> KeyEventFlags
Flags associated with this KeyEvent
.
See the NDK docs
sourcepub fn meta_state(&self) -> MetaState
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
Auto Trait Implementations
impl RefUnwindSafe for KeyEvent
impl !Send for KeyEvent
impl !Sync for KeyEvent
impl Unpin for KeyEvent
impl UnwindSafe for KeyEvent
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more