yew_stdweb::services

Struct KeyboardService

Source
pub struct KeyboardService {}
Expand description

Service for registering callbacks on elements to get keystrokes from the user.

§Note

Elements which natively support keyboard input (such as <input/> or <textarea/>) can use the onkeypress or oninput attributes from within the html macro. You should use those events instead of locating the element and registering an event listener using this service.

This service is for adding key event listeners to elements which don’t support these attributes, (for example the document and <canvas> elements).

Implementations§

Source§

impl KeyboardService

Source

pub fn register_key_press<T: IEventTarget>( element: &T, callback: Callback<KeyPressEvent>, ) -> KeyListenerHandle

Registers a callback which listens to KeyPressEvents on a provided element.

§Documentation

keypress event

§Warning

This API has been deprecated in the HTML standard and it is not recommended for use in new projects. Consult the browser compatibility chart in the linked MDN documentation.

Source

pub fn register_key_down<T: IEventTarget>( element: &T, callback: Callback<KeyDownEvent>, ) -> KeyListenerHandle

Registers a callback which listens to KeyDownEvents on a provided element.

§Documentation

keydown event

§Note

This browser feature is relatively new and is set to replace the keypress event. It may not be fully supported in all browsers. Consult the browser compatibility chart in the linked MDN documentation.

Source

pub fn register_key_up<T: IEventTarget>( element: &T, callback: Callback<KeyUpEvent>, ) -> KeyListenerHandle

Registers a callback that listens to KeyUpEvents on a provided element.

§Documentation

keyup event

§Note

This browser feature is relatively new and is set to replace keypress events. It may not be fully supported in all browsers. Consult the browser compatibility chart in the linked MDN documentation.

Trait Implementations§

Source§

impl Debug for KeyboardService

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<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, V> IntoOptPropValue<V> for T
where T: IntoPropValue<Option<V>>,

Source§

fn into_opt_prop_value(self) -> Option<V>

Convert self to an optional value of a Properties struct.
Source§

impl<T> IntoPropValue<Option<T>> for T

Source§

fn into_prop_value(self) -> Option<T>

Convert self to a value of a Properties struct.
Source§

impl<T> IntoPropValue<T> for T

Source§

fn into_prop_value(self) -> T

Convert self to a value of a Properties struct.
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.
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.
Source§

impl<T> Any for T
where T: Any,