- # check for CTRL-a-q
- return if $ctrl_a_pressed_before == 1 && $char == hex("0x71");
-
- $ctrl_a_pressed_before = ($char == hex("0x01") && $ctrl_a_pressed_before == 0) ? 1 : 0;
+ # Handle escape sequences:
+ if ($in_escape_sequence) {
+ $in_escape_sequence = 0;
+ if ($char == 0x71) {
+ # (escape, 'q')
+ return;
+ } elsif ($char == $escape_char) {
+ # (escape, escape)
+ # Pass this one through as a single escapekey
+ } else {
+ # Unknown escape sequence
+ # We could generate a bell or something...
+ # but for now just skip it
+ next;
+ }
+ } elsif ($char == $escape_char) {
+ $in_escape_sequence = 1;
+ next;
+ }