[][src]Trait winput::Keylike

pub trait Keylike: Copy {
    pub fn produce_input(self, action: Action) -> Input;

    pub fn press(self) -> Result<(), WindowsError> { ... }
pub fn release(self) -> Result<(), WindowsError> { ... }
pub fn send(self) -> Result<(), WindowsError> { ... } }

A trait for objects that can be used as keys. For example a Vk or a char can be used as a key.

Example

use winput::{Vk, Keylike};

Vk::Control.press().unwrap();
Vk::A.trigger().unwrap();
Vk::Control.release().unwrap();

Required methods

pub fn produce_input(self, action: Action) -> Input[src]

Produces an Input that causes the given action to be taken on self.

Panics

This function panics if self was not a valid key. For example, any char that is above 0x0000ffff cannot be turned into an Input.

Example

use winput::{Keylike, Action};

let input = 'A'.produce_input(Action::Press);
winput::send_inputs(&[input]);
Loading content...

Provided methods

pub fn press(self) -> Result<(), WindowsError>[src]

Synthesize an event that presses the key.

Panics

This function panics if self was not a valid key. For example, any char that is above 0x0000ffff cannot be turned into an Input.

Example

use winput::Keylike;

'A'.press().unwrap();

pub fn release(self) -> Result<(), WindowsError>[src]

Synthesizes an event that releases the key.

Panics

This function panics if self was not a valid key. For example, any char that is above 0x0000ffff cannot be turned into an Input.

Example

use winput::Keylike;

'B'.release().unwrap();

pub fn send(self) -> Result<(), WindowsError>[src]

Synthesizes two events. One that presses the key, one that releases the key.

Panics

This function panics if self was not a valid value. For example, any char that is above 0x0000ffff cannot be turned into an Input.

Example

use winput::Keylike;

'C'.trigger().unwrap();
Loading content...

Implementations on Foreign Types

impl Keylike for char[src]

Loading content...

Implementors

impl Keylike for Vk[src]

Loading content...