hotkey

package
v0.38.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package hotkey is the Windows adapter for the global hotkey bus. Dictation, Assist, and Voice Agent each register a binding here; the package translates RegisterHotKey/UnregisterHotKey Win32 calls into channel events the desktop runtime consumes.

Audit 2026-05-24 maintainability sweep.

Index

Constants

View Source
const (
	VkBackspace = 0x08
	VkTab       = 0x09
	VkReturn    = 0x0D
	VkEscape    = 0x1B
	VkSpace     = 0x20

	VkLShift   = 0xA0
	VkRShift   = 0xA1
	VkLControl = 0xA2
	VkRControl = 0xA3
	VkLMenu    = 0xA4 // Left Alt
	VkRMenu    = 0xA5 // Right Alt
	VkLWin     = 0x5B
	VkRWin     = 0x5C
	VkShift    = 0x10
	VkControl  = 0x11
	VkMenu     = 0x12 // Alt
)

Virtual key codes

Variables

This section is empty.

Functions

func ComboAlt

func ComboAlt() []uint32

ComboAlt returns VK code for Alt.

func ComboCtrlShift

func ComboCtrlShift() []uint32

ComboCtrlShift returns VK codes for Ctrl+Shift.

func ComboF8

func ComboF8() []uint32

ComboF8 returns VK code for F8.

func ComboWinAlt

func ComboWinAlt() []uint32

ComboWinAlt returns VK codes for Win+Alt.

func ParseCombo

func ParseCombo(s string) []uint32

ParseCombo parses strings like "alt" or "ctrl+shift+d" into VK codes.

Types

type Event

type Event struct {
	Type    EventType
	Binding string

	// Source identifies the origin of this event. Native keyboard-hook
	// events leave this zero (empty string) which callers must treat as
	// equivalent to EventSourceHotkey. Synthesized events (wake-word,
	// future programmatic triggers) set this explicitly.
	Source EventSource
}

type EventSource added in v0.35.8

type EventSource string

EventSource identifies the origin of a hotkey event.

const (
	// EventSourceHotkey is the default — the event came from a real
	// keyboard press picked up by the platform hotkey manager.
	EventSourceHotkey EventSource = "hotkey"

	// EventSourceWakeword indicates the event was synthesized by the
	// wake-word adapter to simulate a hotkey press. Consumers that need
	// different downstream behaviour for wake-word-triggered activations
	// (e.g. attach an AutoEndPolicy, ignore hold-to-talk semantics)
	// branch on this value.
	EventSourceWakeword EventSource = "wakeword"
)

type EventType

type EventType int
const (
	EventKeyDown EventType = iota
	EventKeyUp
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager captures a push-to-talk key combination through a low-level keyboard hook.

func NewManager

func NewManager(combo []uint32) *Manager

NewManager creates a PTT manager. combo is a list of VK codes that must ALL be pressed.

func (*Manager) Events

func (m *Manager) Events() <-chan Event

func (*Manager) Reconfigure

func (m *Manager) Reconfigure(combo []uint32)

Reconfigure swaps the key combination while the hook is running. The keyboard hook stays installed; only the combo tracker is replaced.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start installs a low-level keyboard hook and emits key down/up events for the configured combo.

func (*Manager) Stop

func (m *Manager) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL