Convert List of Windows.System.Virtualkey to String

548 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.