My program needs to process data and periodically poll for keyboard input.
What function can I use on the third line to check if a key was pressed, without waiting forever for input?
while (1) { sleep(1); if key was pressed { # HELP, how can I check? print "$key was pressed\n"; exit if $key eq 'q'; } do stuff... }
In reply to how to check for keyboard input by redss
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |