Hello,
how to check if Right or Left Ctrl/Strg is pressed ? ( without pressed any other additional key )
main.rs
use k_board::{keyboard::{get_key_from_keyboard, Keyboard}, keys::Keys};
fn main() {
for key in Keyboard::new() {
match key {
Keys::Char('q') => break,
Keys::CtrlL() => println!("Ctrl left"),
Keys::CtrlR() => println!("Ctrl right"),
_ => (),
}
}
}
mod of keys.rs
// All special character keys
#[cfg(any(feature = "standar", feature = "full"))]
pub const STANDAR: [([u8; BYTES], Keys); 40] = [
([0xA2, 0x00, 0x00], Keys::CtrlR),
([0xA3, 0x00, 0x00], Keys::CtrlL),
...
$ cargo check
Checking key v0.1.0 (/home/developer/rust/key)
warning: unused import: `get_key_from_keyboard`
--> src/main.rs:1:26
|
1 | use k_board::{keyboard::{get_key_from_keyboard, Keyboard}, keys::Keys};
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0599]: no variant or associated item named `CtrlL` found for enum `k_board::keys::Keys` in the current scope
--> src/main.rs:8:19
|
8 | Keys::CtrlL() => println!("Ctrl left"),
| ^^^^^ variant or associated item not found in `Keys`
|
help: there is a variant with a similar name
|
8 | Keys::Ctrl() => println!("Ctrl left"),
| ~~~~
error[E0599]: no variant or associated item named `CtrlR` found for enum `k_board::keys::Keys` in the current scope
--> src/main.rs:9:19
|
9 | Keys::CtrlR() => println!("Ctrl right"),
| ^^^^^ variant or associated item not found in `Keys`
|
help: there is a variant with a similar name
|
9 | Keys::Ctrl() => println!("Ctrl right"),
| ~~~~
For more information about this error, try `rustc --explain E0599`.
warning: `key` (bin "key") generated 1 warning
error: could not compile `key` (bin "key") due to 2 previous errors; 1 warning emitted