Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Translating key scan codes to ASCII equivalents
Message
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00454785
Message ID:
00454820
Views:
39
>Hi, George,
>
>These scan codes are not ASCII codes. In the VS Glossary, they are defined as:
>
>"scan code
>A code number transmitted to a computer whenever a key is pressed or released. Each key on the keyboard has a unique scan code. This code is not the same as the ASCII code for the letter, number, or symbol shown on the key; it is a special identifier for the key itself and is always the same for a particular key. When a key is pressed, the scan code is transmitted to the computer, where a portion of the read-only memory basic input/output system (ROM BIOS) dedicated to the keyboard translates the scan code into its ASCII equivalent. Because a single key can generate more than one character—lowercase "a" and uppercase "A," for example—the ROM BIOS also keeps track of the status of keys that change the keyboard state, such as the SHIFT key, and takes them into account when translating a scan code."
>
>I can, of course, create a translations table and do the translation through the table taking into account the modifier keys and all that, but I thought their might be an existing way of getting the ASCII value without the work of building a table.

Are you sure that it's using the scan codes? These can be dependent on the manufacturer and/or locale. Using the scan codes rather than the virual key codes (which Windows sends to applications after translating from the scan code) would be pretty limited. The following is from MS KB article Q104316:

"Keyboard input is acquired by the keyboard driver, which in turn produces a scan code. This scan code is passed on to the locale-specific Win32 subsystem keyboard driver. This locale-specific driver then converts the scan code to a virtual key and a Unicode character. The Win32 subsystem then passes on this information to the application.

All messages in the Win32 application programming interface (API) that present textual information to a window procedure depend upon how the window registered its class. For example, if RegisterClassW() was called, then Unicode is presented; if RegisterClassA() was called, then ANSI is presented. The conversion of the text is handled by the Window Manager. This allows an ANSI application to send textual information to a Unicode application."

It just seems dubious to me that a control would be by-passing the sub-system to get this information.

I did a search on "scan codes" in the MSDN library. There is a chart there that might be useful. The closest thing to an API call would be VkKeyScan, which takes a character and translates it to the virutal key code.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform