[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Keyboard Event issues on Windows (#42)

Nicolas Cellier notifications at github.com
Fri Dec 13 23:09:05 UTC 2019

Note about Ctrl+A/Z: AFAIU, it's what the console app were expected in the ages, so our OS still carry this tribute to legacy...

See how we have to workaround on linux:

Who is turning the keysym into 1 to: 26 charCode?
See https://linux.die.net/man/3/xlookupstring

I also mentionned this in issue #396 

So we might want to do something similar on Windows? (and Mac OS?)
For Win32, see https://docs.microsoft.com/en-us/windows/win32/learnwin32/keyboard-input

MSDN page above explicitely explains that CTRL+A/Z are translated to ASCII control character in the `VM_CHAR` event (as I suggested in preliminary comment, for legacy console app).
It also does not recommend handling CTRL+... or ALT+... thru `WM_CHAR` event, this is not the idiomatic handling on this platform.
And the doc is right - see why below.

The equivalent of linux keysym is the virtual key code (`VK_*`) passed thru wParam in `WM_KEYDOWN` event.

The problem is that we effectively get the keycode in case of `WM_KEYDOWN` event, but not in case of `VM_CHAR` event: `msg->wParam` holds an UTF-16 Unicode character the doc says...

So, IMO, we should better generate an extra OpenSmalltalk `EventKeyChar` event in response to `WM_KEYDOWN` event when we detect a CTRL down status, and filter out the event in case of `VM_CHAR` with CRTL down...

Note that Pharo VM uses `MapVirtualKey` with `MAPVK_VSC_TO_VK` to handle ctrl+char
Though it's not clear where the usage of `msg->lParam` comes from (`MapVirtualKey` expects a scan code, which is low level keyboard code and will return a VK code that fortunately matches ASCII for A to Z keys...), I've not seen it documented in official MSDN, it would be good to have a link documenting it.
It's not the way that MSDN (and I) recommended above, but might eventually work (I'm not in a position to understand if there are other side effects...)

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20191213/62f1390b/attachment.html>

More information about the Vm-dev mailing list