17 releases

0.5.1 Dec 6, 2022
0.5.0 May 13, 2022
0.4.8 Jan 2, 2022
0.4.7 Oct 11, 2021
0.1.1 Jul 31, 2021

#1361 in Hardware support

Download history 1/week @ 2024-06-26 47/week @ 2024-07-03 48/week @ 2024-07-24 20/week @ 2024-07-31 19/week @ 2024-09-18 40/week @ 2024-09-25

59 downloads per month

MIT/Apache

105KB
2.5K SLoC

hookmap

Crates.io API reference

Register hotkeys and simulate keyboard and mosue input.

Supported OS

  • Windows 10

Example

use hookmap::prelude::*;

fn main() {
    let mut hotkey = Hotkey::new();

    // Remap H,J,K,L keys as in vim.
    hotkey
        .register(Context::default())
        .remap(Button::H, Button::LeftArrow)
        .remap(Button::J, Button::DownArrow)
        .remap(Button::K, Button::UpArrow)
        .remap(Button::L, Button::RightArrow);

    // You can define hotkeys that work only when specific keys are pressed or released.
    hotkey
        .register(
            Context::new()
                .modifiers(buttons!(LCtrl, !RShift))
                .native_event_operation(NativeEventOperation::Block),
        )
        .on_press(Button::Space, |_| {
            seq!(with(LCtrl), A).send_ignore_modifiers();
        })
        .disable(buttons!(A, B))
        .on_release(buttons!(A, B), |event: ButtonEvent| {
            seq!(with(LShift), [event.target]).send_ignore_modifiers();
        });

    hotkey.install();
}

Dependencies

~1–26MB
~352K SLoC