blockable_binds/blockable_binds.rs
1use inputbot::{BlockInput::*, KeybdKey::*};
2
3// This example demonstrates blocking input with conditional flags, such as another key being
4// pressed or toggled. This example currently does not work on Linux.
5
6fn main() {
7 // Block the A key when left shift is held. Note: callbacks for blockable binds won't be
8 // executed in new threads, so for long-running processes create new threads inside the callback
9 // if needed.
10 AKey.blockable_bind(|| {
11 if LShiftKey.is_pressed() {
12 Block
13 } else {
14 DontBlock
15 }
16 });
17
18 // Block the K key when left shift is held.
19 KKey.block_bind(|| ());
20
21 // Call this to start listening for bound inputs.
22 inputbot::handle_input_events();
23}