takkaria, unsurprisingly, even figured out how to do it

The best typists can type about 600 symbols per minute. (I heard in typing competitions they use stenography, and special keyboards with "chords" - no idea what that is - and then can show about 1200 symbols/min, but 600 is a pretty reasonable limit for a normal human with a standard keyboard). That's 10 symbols/sec, or 1 symbol in 100 milliseconds, which is a considerable time... Of course, 600 is average, and peak speed is higher than that, but if keypresses come faster than, say, once per 50 msecs, it means that the user is holding down a key, or pressed several keys (almost) simultaneously. So the pseudocode looks like:
Code:
void get_input() {
static time_t previous_time;
while (true) {
key k = get_key();
time_t t = get_time();
if (t - previous_time >= KEY_REPEAT_RATE_IN_MSECS) {
Term_keypress(k);
previous_time = t;
return;
}
// else just forget this key, and read the new one
}
}
I implemented that in textui2 (but I forgot the previous key thing). That's how all key repeat limiters work, and it doesn't feel non deterministic or anything, if it allows, say, 20 keys per second. After that the difference can only be percieved when holding down a key.
As for flushing the input queue, you can just read from it until it's empty, and, btw, Angband already has TERM_XTRA_FLUSH, which is supposed to do exactly that.
Leave a comment: