Convert string to key

Feb 10, 2013 at 10:10pm
Hello, is there any way to convert a string of a key, such as "A" or "Shift" into a char or VK_Keycode?
Thanks.
Last edited on Feb 11, 2013 at 4:33pm
Feb 11, 2013 at 9:56am
No. It depends on the keyboard.

You can hardcode values of particular keyboard, but I don't know how to do it "properly".
Feb 11, 2013 at 1:30pm
Oh, ok.
Feb 11, 2013 at 4:31pm
Feb 11, 2013 at 4:36pm
That's not what I'm looking for.
Feb 12, 2013 at 8:33pm
Feb 12, 2013 at 9:08pm
Well...

1. Converting "A" into a char is just a case of using operator[]?

2. Isn't the virtual key code keyboard independent? And the hardware specific one the scan code?

(The virtual key codes are defined as fixed values in WinUser.h

The virtual key codes for A - Z are the ascii values for the corresponding uppercase letter.)

Out of interest, what do you need the codes for??

Andy
Last edited on Feb 12, 2013 at 9:08pm
Feb 12, 2013 at 9:25pm
Ah, looking again I now understand what he means. There is no global way to do it, I think, you should just handle each key manually (Maybe just make a table of possible "long names" and compare)
Feb 12, 2013 at 10:19pm
Ok, thanks. I'll probably make a function for it then.
Topic archived. No new replies allowed.