1
0
Fork
You've already forked sokey
0
No description
  • Zig 100%
Mikael Säker 1297c859a4 deps: repin sokol to the reachable deadkeys head
The old pin (78fdd365) predates a force-push and is unreachable from any ref — cold fetches failed. 8bed105f is the current deadkeys branch head.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026年07月06日 22:14:54 +02:00
src Expose translateLogical for ad-hoc lookups 2026年05月08日 23:16:14 +02:00
.gitignore Initial sokey: sokol keyboard event coalescing with layout-aware logical keys 2026年04月29日 07:40:11 +02:00
build.zig Initial sokey: sokol keyboard event coalescing with layout-aware logical keys 2026年04月29日 07:40:11 +02:00
build.zig.zon deps: repin sokol to the reachable deadkeys head 2026年07月06日 22:14:54 +02:00
README.md Initial sokey: sokol keyboard event coalescing with layout-aware logical keys 2026年04月29日 07:40:11 +02:00

sokey

Sokol keyboard event coalescing with layout-aware logical keys.

What it does

sokol_app delivers keyboard input as three separate event types (KEY_DOWN, CHAR, KEY_UP). sokey coalesces them into a single KeyEvent per logical press/release that carries:

  • physical — sokol's positional keycode (right answer for arrows, F-keys, modifier-only chords like Cmd+Q)
  • logical — layout-aware unmodified key (right answer for game action bindings and vim-style commands; matches the cap the user sees with the active layout)
  • text — UTF-8 of what the OS would type into a text field (right answer for in-game text input, with shift, dead-keys, IME applied)
  • mods — modifier state at event time
  • kinddown / up / repeat

Both game-style action mapping and text input read from the same stream; each consumer picks the field it needs.

Status

  • macOS: layout-aware via Carbon's TIS / UCKeyTranslate.
  • Windows: stub — logical returns null. Falls back to positional.
  • Linux: stub — same.

Usage

constsapp=@import("sokol").app;constsokey=@import("sokey");exportfnevent(ev_ptr:[*c]constsapp.Event)void{sokey.feed(&ev_ptr[0]);}fnframe()void{sokey.flushPending();while(sokey.poll())|ke|{// ke.physical, ke.logical, ke.text(), ke.mods, ke.kind}}pubfnmain()void{sokey.disablePressAndHold();// macOS QoL: hold-to-repeatsapp.run(.{.event_cb=event,.frame_cb=frame,...});}

Tests

zig build test