#input #keyboard-input #mouse #mouse-input #keyboard #mouse-event

claves

A library for capturing Keystrokes and Mouse clicks on Linux, MacOS and Windows

6 releases

0.2.0 Sep 16, 2023
0.1.4 Aug 18, 2023
0.1.3 Jul 7, 2023
0.1.2 Mar 17, 2023
0.1.1 Sep 28, 2022

#25 in Accessibility

MIT license

21KB
533 lines

Claves - A library for capturing global Keystrokes and Mouse clicks on MacOS and Windows

use claves::{init, deinit};

fn main(){
  // Global channel, you can initiate a receiver from multiple threads and all of them will receive the events.
  let receiver = init();
  
  dbg!(receiver.recv().unwrap());
  
  // Deinitializes all threads that capture data from the keyboard and mouse, then empties out the global channel.
  deinit();
}

  • MacOS (Uses Core Graphics API to intercept Session Events and Carbon API to translate Virtual Keycodes into Unicode Characters). Requires Accessibility permissions, check the MacOS Example.
  • Windows (Uses Windows Hooks API to intercept Events and the Winuser API to translate Virtual Keycodes into Unicode Characters).
  • Linux. Not planned for now.

Dependencies

~0.3–12MB
~79K SLoC