Two choices, depending on details you didn't tell.
1. Write your own dedicated keyboard driver, that implements this filtering.
2. Make your application program such, that it reads single characters from the input and filters them according to your timing rules.

Kees