Filtering key strokes

  • Thread starter Thread starter zed
  • Start date Start date
Z

zed

Hi,

having a card reader attached to the PS/2 keyboard interface, I would
like to filter the keyboard input, so that the input from the card
reader does not reach the GUI controls.

I tried setting KeyPreview=true on the form and catched all input with
the KeyDown event. In order to detect, if the input comes from the
card reader, I need to check a sequence of at least 10 keys. So I
collect the keys in KeyDown and if it's a card reader sequence, I
trigger a special action for it. If it's normal user input, I need to
"forward" the collected key strokes to the form.

The second part is the complicated one. Having a sequence of key
strokes in an array of type System.Windows.Forms.Keys, how do I resend
these to the application? Sendkeys only accepts a string and seems to
not support all values of the System.Windows.Forms.Keys enum.

Is there maybe a way to resend keystrokes using the integer values
captured from the KeyValue member of the KeyEventArgs?

bye,

Marc T.
 
Every card reader that I've used that goes in line with the keyboard
provides input that is indistinguishable from the real keyboard.

The only successful solution that I have found is to use a non keyboard
interface for example, a serial port.
 
I couldn't find a nice solution so I now assume, that the card reader
(or iButton key lock) sends a hotkey that is not allowed to be used
for any other purpose. When the form detects the hotkey in KeyDown, it
hides the key strokes from the controls and collects them until a
small timeout is triggered. The collected keystrokes are then matched
against a Regexp and appropriate action is taken. It works with the
hardware I currently use, but might be a problem the future.
 
Back
Top