OK, I will caveat this by saying that I am not an expert in this sort of coding, and even less so by using Java.
However, I understand that Java allows for the events of KeyPressed, Key Typed and KeyReleased. Thus, the coding may want to look for key-release as the main event?
I think the answer would depend on what language you use for coding the input in - perhaps your own DLL?
Cheers,
DK