examples/hid/kbhit/kbhit.ck
raw| 1 | // name: kbhit.ck |
| 2 | // desc: KBHit (terminal only) is a simple mechanism for capturing |
| 3 | // keyboard input (for a more flexible mechanism, see HID) |
| 4 | |
| 5 | // the event |
| 6 | KBHit kb; |
| 7 | |
| 8 | // time-loop |
| 9 | while( true ) |
| 10 | { |
| 11 | // wait on kbhit event |
| 12 | kb => now; |
| 13 | |
| 14 | // potentially more than 1 key at a time |
| 15 | while( kb.more() ) |
| 16 | { |
| 17 | // print key value |
| 18 | <<< "ascii: ", kb.getchar() >>>; |
| 19 | } |
| 20 | } |
| 21 |