Thread: Keyboard input and TranslateMessage

  1. #1
    Registered User
    Join Date
    May 2018

    Keyboard input and TranslateMessage

    As the doc (Keyboard Input (Windows)) 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?

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Well, it takes into account many things, like the key that is currently pressed plus whether or not a Shift key is pressed plus whether or not CapsLock or NumLock are on. Then it combines that information with the current locale (keyboard layout and character encoding) to produce the appropriate character.
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TranslateMessage() without a window?
    By w4ck0z in forum Windows Programming
    Replies: 3
    Last Post: 08-08-2009, 02:07 AM
  2. Keyboard Input
    By CaliJoe in forum C++ Programming
    Replies: 3
    Last Post: 05-08-2009, 09:51 AM
  3. Keyboard Input
    By stuartbut in forum C Programming
    Replies: 1
    Last Post: 03-21-2003, 11:09 AM
  4. Keyboard Input ?
    By Malikive in forum C++ Programming
    Replies: 9
    Last Post: 11-08-2001, 01:30 PM
  5. Keyboard input ?
    By Malikive in forum Game Programming
    Replies: 4
    Last Post: 11-06-2001, 11:14 PM

Tags for this Thread