Tauri Plugin Key Intercept banner
yigitkonur yigitkonur

Tauri Plugin Key Intercept

Development community

Description

Tauri plugin to intercept macOS system shortcuts via CGEventTap

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Tauri v2 plugin that intercepts global keyboard events at the hardware level on macOS. uses `CGEventTap` FFI to steal keypresses before the OS sees them — so you can override system shortcuts like F5 (dictation) without asking nicely.

app.plugin(tauri_plugin_key_intercept::init())

[![crates.io](https://img.shields.io/crates/v/tauri-plugin-key-intercept.svg?style=flat-square)](https://crates.io/crates/tauri-plugin-key-intercept) [![rust](https://img.shields.io/badge/rust-1.77.2+-93450a.svg?style=flat-square)](https://www.rust-lang.org/) [![license](https://img.shields.io/badge/license-MIT_|_Apache--2.0-grey.svg?style=flat-square)](https://opensource.org/licenses/MIT)


how it works

inserts a `CG_HEAD_INSERT_EVENT_TAP` at `CG_HID_EVENT_TAP` position — highest priority in the macOS event chain, before any other listener. when a registered hotkey fires, the C callback returns `NULL` to consume the event (OS never sees it) and emits a Tauri event to your frontend with the keycode and modifier flags.

same technique used by BetterTouchTool and similar tools. runs on a dedicated thread with its own `CFRunLoop`, fully idle at 0.0% CPU between events.

what it does

  • hardware-level event tapCGEventTap FFI, not NSEvent global monitors
  • consume or passthrough — per-hotkey choice to block the OS or let the event propagate
  • both keycode modes — register standard and media keycodes simultaneously (e.g. F5 = [96, 176])
  • modifier filtering — strips internal macOS flags (fn, caps lock, numpad), matches only intentional modifiers (cmd, opt, ctrl, shift)
  • runtime permission check — probes CGEventTapCreate to verify Input Monitoring access without side effects
  • deep-link to settings — opens System Settings directly at Privacy > Input Monitoring
  • cross-platform safe — compiles on all platforms, returns UnsupportedPlatform on non-macOS

install

Rust side

add to your `src-tauri/Cargo.toml`:

[depende