Found the bug!
Actually, WMD listens to the
keydown event which contains a
keyCode and no
keypress actually contains a
charCode) but considers
charCode to be the same thing.
This is wrong!
charCode may give you the same letter, but that is not true for every letter.
String.fromCharCode(107) == 'k' // 107 is the charCode for "k"
String.fromCharCode(75) == 'K' // 75 is the keyCode for key K
Wow, the fact that the
keyCode of K is the same as the
charCode of "K" charCode is only a coincidence (or maybe history). But this is not true for every keys!
String.fromCharCode(107) == 'k' // 107 is the keyCode for key =
String.fromCharCode(61) == '=' // 61 is the charCode for "="
So when typing k, WMD sees no
charCode (since it handles
keydown) and uses the
keyCode 75 instead which gives
K. That's why Ctrl+K is working as expected.
But when typing =, WMD still sees no
charCodeand used the
keyCode 107 which gives
k. Boom, WMD thinks we typed Ctrl+K while we actually typed Ctrl+Alt+= (this is how you type a
} on azerty french keyboard).
How to fix it
Actually, it's not that easy.
Relying on the
keydown event means that there is no easy way to know what character has been typed, only what key has been typed.
But we can still rely on the
keyCode being 75 to trigger our shortcut. This means that it may not be the same letter for everyone.