+$hook{main} = sub {
+ while (1) {
+ draw();
+
+ my $key = chr SLang_getkey; # wait for user input
+ if ($key eq chr 27) {
+ $key .= chr SLang_getkey while SLang_input_pending(0)==1; # read additional keys
+ } # escape sequence
+# error(join " ", map ord, split //, $key); #debug
+ onkey($key);
+ } # input loop
+}; # main
+