Keyboard input and TranslateMessage

As the doc ("https://msdn.microsoft.com/pl-pl/library/windows/desktop/gg153546(v=vs.85).aspx") about the windows keyboard input says

Key strokes are converted into characters by the TranslateMessage function


My question is how doues the `TranslateMessage` function really works in the hood. How does it translate the key-down messages (`WM_KEYDOWN, WM_SYSKEYDOWN`) to character massage (`WM_CHAR, WM_SYSCHAR`)?

To clear up what i'm talking about here is the use case: when i set the keyboard layout to Polish when i press the `ALT key + a` i get the `ą` letter then when i change the layout to Turkey for e.g. a get the `æ` letter with different charcode then `ą` letter with Polish layout. How does the `TranslateMessage` utilize the current keyboard layout to produce differet charcodes for differet layouts? Does it use some kind of language tables/files/dlls to lookup the right charcode for selected layout?
Last edited on
So the keyboard sends a message to the OS based on what key is pressed on the keyboard. This code from the physical hardware, called the scan code, remains constant per device. The OS then references a Keyboard Keymap to see what that message should translate to based on the current configuration and forwards that translated keycode to whatever has focus. This keymap is what is changed based on your user language settings.

Here's a link to a more authoritative answer than myself in case this is for an assignment or what not: https://msdn.microsoft.com/en-us/library/windows/desktop/gg153546(v=vs.85).aspx
Last edited on
Topic archived. No new replies allowed.