You can try `illwill`. It's a nice 3rd party lib that provides a non-blocking keyboard input, that might set you on the right path. <https://github.com/johnnovak/illwill>
example for usage illwillInit(false,false) # inits non-blocking keyboard input (params are for fullscreen, mouse capture) proc exit() = illwillDeinit() # resets terminal to its previous state showCursor() # show cursor if it was hidden quit(0) proc getInput() = while true: var key = getKey() case key of Key.Escape: exit() # of Key.R: #logic else: discard break Run