0

I'm creating an application which will capture a string from an USB attached scanner. I don't want a text box on the form I'm capturing the data on so I've added a handler to the KeyDown event of the window. There is a specific sequence of key presses I can look for to start capturing the data, however, what I can capture is a list of Virtualkeys. That would include LeftShift, v for 'V'

I'm looking for a way to take the array of Virtualkeys and convert that to a string.

Or if you can suggest another way to catpure the text, maybe hidden textbox?

UPDATE

I've positioned a textbox off window and was able to maintain keyboard focus on it so I could capture the data from the barcode scanner.

VFein
  • 1,021
  • 2
  • 11
  • 23
  • Have you looked in [this answer](http://stackoverflow.com/questions/554015/how-to-convert-from-virtual-key-codes-to-system-windows-forms-keys)? What string do you expect at the end? – Ilya Luzyanin Dec 23 '16 at 20:38
  • Thanks, I did see similar answers, but they seems to not account for things like shift keys, or shift lock. – VFein Dec 24 '16 at 02:16

1 Answers1

0

You can get info whether any VirtualKey is pressed using this:

bool isPressed = Window.Current.CoreWindow.GetKeyState(VirtualKey).HasFlag(CoreVirtualKeyStates.Down);

AFAIK this is the best way of getting to know whether more keys are pressed at the same time.

Marian Dolinský
  • 3,312
  • 3
  • 15
  • 29