What’s wrong with TranslateMessage?  Two things:

  1. It probably shouldn’t be in the message loop.  Different windows do different things with character and keystroke messages.  Performance is not an issue here nowadays.  Having TranslateMessage in the message loop has resulted in awful things such as IsDialogMessage and TranslateAccelerator calls for every message that goes through the loop.
  2. More importantly though, TranslateMessage really should return TRUE if the keystroke message generates characters.  It should return FALSE in every other situation.  Unfortunately, TranslateMessage currently returns TRUE for WM_*KEYDOWN messages, even if no characters are generated by the keystroke (think F2 or Ctrl or up-arrow or Ctrl+Shift+X).  This means that application developers have no way of knowing if the key can be safely used as a shortcut key, or should be ignored because a WM_CHAR or similar is on its way to insert into the current focus.

    This in turn means that shortcut keys are typically processed (with TranslateAccelerator or a homegrown variety thereof) before TranslateMessage – and some characters are now inaccessible on some keyboard layouts.

    The typical workaround is to add a hack for Ctrl+Alt (AltGr).  Yuck.  And that doesn’t solve other supported combinations such as Ctrl+Shift.

So what’s the answer to these problems? TranslateMessageEx?

Categories: Developing Keyman

Related Posts

Developing Keyman

Keyman Update for 28 August 2026

Major improvements on Autocorrect! These alpha versions bring localization on Windows, Linux, iOS. Keyman for Windows has support for PNG format icon, track caps lock state correctly. Keyman Developer fixes unsaved layer name, continue on kmc-convert. While, Keyman for Android and iPhone and iPad has new documentation on autocorrection. KeymanWeb enhances suggestion, memory-usage, and supports complex Latin-script languages. Improvements on the Laz keyboard. New Medžuslovjansky (latinica), Ligurian, Ntcham (AZERTY), and kachin keyboards! Don't forget about our 3 new contributors and another testimonial!

Developing Keyman

Keyman Update for 14 August 2026

This edition highlights the latest Keyman product and keyboard development updates from 3 — 14 August 2026, describing recent progress across the project and contributions from the community. A few links Learn how to create Read more…

Developing Keyman

Keyman Internship 2026 – Android UI

Earlier this year, the Keyman team working out of the National Polytechnic Institute of Cambodia (NPIC), វិទ្យាស្ថានជាតិពហុបច្ចេកទេសកម្ពុជា, in Phnom Penh, the capital of Cambodia, offered an internship program to keen students to take on a Read more…