Created
October 27, 2022 20:05
-
-
Save gfldex/abebd2c82c79858a43763bb1bf564412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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