console enhancements: mouse events

Andy Koppe
Sat Nov 7 11:50:00 GMT 2009

2009/11/7 Corinna Vinschen:
>> Mintty roughly does the following for Ctrl(+Shift)+symbol combinations:
>> - obtain the keymap using GetKeyboardState()
>> - set the state of the Ctrl key to released
>> - invoke ToUnicode() to get the character code according to the keyboard layout
>> - if the character code is one of [\]_^? send the corresponding control code
>> - otherwise, set the state of both Ctrl and Alt to pressed (this is
>> equivalent to AltGr), and try ToUnicode() again
>> The last step means that e.g. Ctrl+9 on a German keyboard will send
>> ^]. The proper combination would be Ctrl+AltGr+9, but since
>> AltGr==Ctrl+Alt, that can't be distinguished from AltGr+9 without
>> Ctrl. (Well, not without somewhat dodgy trickery anyway.)
> How does that work for ^^?  The ^ key is a deadkey on the german keyboard
> layout, so the actual char value is only generated after pressing the key
> twice.  Just curious.

ToUnicode actually delivers the ^ character right away when pressing
the key, but with return value -1 to signify that it's a dead key and
that the next key will be modified accordingly. So for Ctrl+^, mintty
sends ^^ right away and then clears the dead key state using a trick
picked up from
feed VK_DECIMALs into ToUnicode until it stops returning dead-key

(Yep, it's a terrible API for an unintuitive feature. See also


More information about the Cygwin-patches mailing list