views:

540

answers:

3

During development i have observed that certain PDAs with Windows CE and possibly Windows Mobile too are sending the Enter key twice in the key pressed event thus i execute twice the code that lies under the control's key press event for the return button.

I suspect that this is a hardware bug and i would like to ask how you resolved it without changing your application logic.

A: 

I don’t know if this will help but if you read the keyboard port Enter is seen as two bytes rather than one.

A: 

Without changing the logic? You really can't (unless there is a hardware or firmware fix). I'd guess the simplest mechanism (that requires a logic change) is to treat two Enter keys or keypresses in a short period (say < 100ms) then ignore the second.

ctacke
Due to the possibility that the operation it invokes might take > 100 ms and keys are processed sequentially. I'd suggest doing the opposite. Hold back on processing the enter and wait a while to see if another arrives before processing one of them.
Quibblesome
A: 

This happened to me too and it turned out it was because the "enable character repeat" option was enabled in control panel->keyboard. The default repeat delay was way too fast for the keypad that we used, so I just slowed it down and the problem went away.

Scott Anderson