<p>Since X11 does not provide a localized version of virtual keys, I mapped the X11 event's <code>KeySym</code> to such a "virtual-key code", using <code>evt.keycode</code> only as a fall back. It's not perfect but close to what Windows and macOS have.</p>
<p>Here is the mapping schema:</p>
<div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content=" * 0x00         (unknown virtual key)
 * 0x01         XK_space (shifted from Latin-1)
 * 0x02         XK_comma (shifted from Latin-1 OR guessed from xKeycode)
 * 0x03         XK_period (shifted from Latin-1 OR guessed from xKeycode)
 * 0x04 .. 0x07 (unused)
 *
 * 0x08 .. 0x1f SPECIAL KEYS 1 (from all-mask 0xff00)
 * 0x20 .. 0x29 NUMERIC ASCII KEYS (shifted from Latin-1)
 * 0x2a .. 0x43 ALPHABETIC ASCII KEYS (shifted from Latin-1)
 *
 * 0x44         US_MINUS (guessed from xKeycode)
 * 0x45         US_PLUS (guessed from xKeycode)
 * 0x46         US_LBRACKET (guessed from xKeycode)
 * 0x47         US_RBRACKET (guessed from xKeycode)
 * 0x48         US_COLON (guessed from xKeycode)
 * 0x49         US_QUOTE (guessed from xKeycode)
 * 0x4a         US_TILDE (guessed from xKeycode)
 * 0x4b         US_BACKSLASH (guessed from xKeycode)
 * 0x4c         US_COMMA (guessed from xKeycode)
 * 0x4d         US_PERIOD (guessed from xKeycode)
 * 0x4e         US_SLASH (guessed from xKeycode)
 * 0x4f         US_102 (guessed from xKeycode)
 *
 * 0x50 .. 0xff SPECIAL KEYS 2 (from all-mask 0xff00)
"><pre><code> * 0x00         (unknown virtual key)
 * 0x01         XK_space (shifted from Latin-1)
 * 0x02         XK_comma (shifted from Latin-1 OR guessed from xKeycode)
 * 0x03         XK_period (shifted from Latin-1 OR guessed from xKeycode)
 * 0x04 .. 0x07 (unused)
 *
 * 0x08 .. 0x1f SPECIAL KEYS 1 (from all-mask 0xff00)
 * 0x20 .. 0x29 NUMERIC ASCII KEYS (shifted from Latin-1)
 * 0x2a .. 0x43 ALPHABETIC ASCII KEYS (shifted from Latin-1)
 *
 * 0x44         US_MINUS (guessed from xKeycode)
 * 0x45         US_PLUS (guessed from xKeycode)
 * 0x46         US_LBRACKET (guessed from xKeycode)
 * 0x47         US_RBRACKET (guessed from xKeycode)
 * 0x48         US_COLON (guessed from xKeycode)
 * 0x49         US_QUOTE (guessed from xKeycode)
 * 0x4a         US_TILDE (guessed from xKeycode)
 * 0x4b         US_BACKSLASH (guessed from xKeycode)
 * 0x4c         US_COMMA (guessed from xKeycode)
 * 0x4d         US_PERIOD (guessed from xKeycode)
 * 0x4e         US_SLASH (guessed from xKeycode)
 * 0x4f         US_102 (guessed from xKeycode)
 *
 * 0x50 .. 0xff SPECIAL KEYS 2 (from all-mask 0xff00)
</code></pre></div>
<p>Here is the new mapping table for Squeak:<br>
<a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/files/7269113/new-x11-virtual-keys.1.cs.txt">new-x11-virtual-keys.1.cs.txt</a></p>
<p>See /usr/include/X11/keysymdef.h to understand the "SPECIAL KEYS" (masked 0xff00).</p>
<p>The biggest remaining issue is all those "OEM keys", which means the ones you push for "+" or "/" or "~" and so on.</p>
<p><em>Note that the idea of having a localized version of the virtual key is that you can print it in an application's user interface. Would be really annoying if an app insists on, e.g., Z while you actionally pushed Y.</em></p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599'>https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599/commits/4c64947be11eef4a4b567852edb4bd231b7a90e2">For keyDown and keyUp events, pass keycodes into the image. Not quite the virtual keys on other platforms because no information about locale.</a></li>
  <li><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599/commits/147f7d63e70e380331eddb524a90828aa8b0dd8e">Prepare skeleton for xkey2sqVirtualKeyCode(). Fix several several naming issues: keyCode -> ascii, codes -> keyNameEntries, nameForKeycode -> nameForKeysym</a></li>
  <li><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599/commits/ff3c42659822b528d49f578538e434d1acae4fd1">Compute a virtual-key code using X11's KeySym and -- as a fall-back -- that event's not-localized KeyCode.</a></li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599/files#diff-bde6d852f3eaff3d4caa065c6bae7b9c2258516f4fb122756b60e9ac1a96f521">platforms/unix/vm-display-X11/sqUnixX11.c</a>
    (181)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599.patch'>https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599.patch</a></li>
  <li><a href='https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599.diff'>https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AIJPEWZP6FCRQX6XT766HKDUEXXZJANCNFSM5FFF5FHQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AIJPEW23X3JXSR2GHN34LDDUEXXZJA5CNFSM5FFF5FH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4PDKQDYA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599",
"url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/599",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>