<p></p>
<blockquote>
<p>Keyboards don't create unicode code points.</p>
</blockquote>
<p>You are right, keyval is not always a code point, although often coincidentally the value happens to be the same <g-emoji class="g-emoji" alias="smile" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f604.png">😄</g-emoji>. But keyval does use at least 25 bits (see cyrillic or armenian in <code>gdkkeysyms.h</code>) so its worse than I thought.  Also on some keyboards with "dead" keys GDK maps a multiple key sequences into one key event without IME.  And IME still generates a keyevent IIUC with Unicode keyvals.</p>
<blockquote>
<p>Most keyboards have fewer than 128 keys.</p>
</blockquote>
<p>Not true, some non-asian keyboards have up to 4 values per keycap, see <a href="https://en.wikipedia.org/wiki/File:Azerty_NFZ71-300.png" rel="nofollow">French</a> or probably <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/eht16/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/eht16">@eht16</a>'s German keyboard.  And also <em>which</em> values?  As you can see in <code>gdkkeysyms.h</code> keyval can cover a wide range of values.  A simple table of all possible keyvalues from keyval to function address is far too big even if state is handled separately.</p>
<p>Thats why I suggest a hash table (or binary tree), key is combined <code>keyval</code> and <code>state</code> from the event and value is the function to call, the number of entries is related to the number of active keybindings, not the number of possible key values and the performance is constant for hash and O(ln(entries)) for tree (say 7 compares of a 64 bit value if 128 keybindings are set).  Because keyvals from any one keyboard are likely to be close to sequential the combination and hash of <code>keyval</code> and <code>state</code> needs to ensure that performance does not approach linear worst case if hash is used, probably tree is safer because it doesn't have the bad worst case performance.  Don't know which is easier to use/maintain.</p>
<p>Keyboards are a real pain, see also <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="200745970" data-permission-text="Title is private" data-url="https://github.com/geany/geany/issues/1368" data-hovercard-type="issue" data-hovercard-url="/geany/geany/issues/1368/hovercard" href="https://github.com/geany/geany/issues/1368">#1368</a> for another saga.</p>

<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/geany/geany/pull/2956#issuecomment-954402073">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJYLPAQHZM75DEM35JLUJIIQ7ANCNFSM5GYIYOCQ">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/AAIOWJ3KZJDT7MGO6AC4D6LUJIIQ7A5CNFSM5GYIYOC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHDRQKGI.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/geany/geany/pull/2956#issuecomment-954402073",
"url": "https://github.com/geany/geany/pull/2956#issuecomment-954402073",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>