Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created October 27, 2022 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfldex/abebd2c82c79858a43763bb1bf564412 to your computer and use it in GitHub Desktop.
Save gfldex/abebd2c82c79858a43763bb1bf564412 to your computer and use it in GitHub Desktop.
use v6.d;
constant @keymap = (0x1b, 0x5b, 0x31, 0x31, 0x7e) => 'F1', (0x61,) => 'a', (0x0a,) => 'ENTER';
use Term::ReadKey;
react {
whenever key-pressed( :!echo ) {
state @stack;
@stack.push: .ord;
# .ord.fmt('%02x').put; # uncomment to discover new keycodes
with @keymap.first({ .key ~~ @stack }) {
say .value;
@stack = [];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment