Skip to content

all: widen Key to uint32 on every platform#42

Merged
changkun merged 1 commit into
mainfrom
feat/key-uint32
Jun 6, 2026
Merged

all: widen Key to uint32 on every platform#42
changkun merged 1 commit into
mainfrom
feat/key-uint32

Conversation

@changkun

@changkun changkun commented Jun 6, 2026

Copy link
Copy Markdown
Member

Foundational change for media-key support (#28). Media keys need wider codes than the current Key types allow:

  • X11 XF86* keysyms (e.g. XF86AudioPlay = 0x1008FF14) overflow uint16.
  • macOS needs more than uint8 to disambiguate media keys from Carbon keycodes.

Unifies Key as uint32 on all platforms (was uint8 on darwin/nocgo, uint16 on linux/windows). Uniform width also removes a longstanding per-platform divergence.

Source-compat note: code doing an explicit narrowing cast like uint16(key) needs updating. hotkey.KeyA, hotkey.Key(0x15), and comparisons are unaffected. Verified by build + existing tests on all platforms.

Foundation for the Linux/Windows media constants and the macOS CGEventTap backend that follow.

Media-key support needs wider key codes than the current types allow:
X11 XF86* keysyms such as XF86AudioPlay (0x1008FF14) overflow uint16,
and macOS needs more than uint8 to disambiguate media keys from Carbon
keycodes. Unify Key as uint32 across all platforms (was uint8 on
darwin/nocgo, uint16 on linux/windows).

Minor source-compatibility note: code doing an explicit narrowing cast
like uint16(key) needs updating; hotkey.KeyA and hotkey.Key(0x15)
are unaffected.
@changkun changkun merged commit 404034a into main Jun 6, 2026
19 checks passed
@changkun changkun deleted the feat/key-uint32 branch June 6, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant