If a Key-down event didn't meet the expected criteria,
the event was ignored in the "peek" loop, but it was
never removed from the input queue either, so it
remained at the top of the queue.
It isn't clear if this fixes the dedicated arrow keys
hanging, but if those were resulting in strange
event values too, it just might.
if (ch || iskeypad(scan) || altseq) {
done = 1; /* Stop looking */
retval = 1; /* Found what we sought */
+ } else {
+ /* Strange Key event; let's purge it to avoid trouble */
+ ReadConsoleInput(hConIn,ir,1,&count);
}
+
}
else if ((ir->EventType == MOUSE_EVENT &&
(ir->Event.MouseEvent.dwButtonState & MOUSEMASK))) {
if (ch || iskeypad(scan) || altseq) {
done = 1; /* Stop looking */
retval = 1; /* Found what we sought */
+ } else {
+ /* Strange Key event; let's purge it to avoid trouble */
+ ReadConsoleInput(hConIn,ir,1,&count);
}
+
}
else if ((ir->EventType == MOUSE_EVENT &&
(ir->Event.MouseEvent.dwButtonState & MOUSEMASK))) {
if (ch || iskeypad(scan) || altseq) {
done = 1; /* Stop looking */
retval = 1; /* Found what we sought */
+ } else {
+ /* Strange Key event; let's purge it to avoid trouble */
+ ReadConsoleInput(hConIn,ir,1,&count);
}
+
}
else if ((ir->EventType == MOUSE_EVENT &&
(ir->Event.MouseEvent.dwButtonState & MOUSEMASK))) {