Skip to content

Commit

Permalink
WIP: US-International Keyboard Deadkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
kwibus committed Oct 15, 2024
1 parent ed1fef4 commit 77f74e3
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
36 changes: 36 additions & 0 deletions core/input/keysym.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
/* eslint-disable key-spacing */

export default {
// TODO remove unused
XK_dead_grave: 0xfe50, // `
XK_dead_acute: 0xfe51, // ´
XK_dead_circumflex: 0xfe52, // ^
XK_dead_tilde: 0xfe53, // ~
XK_dead_macron: 0xfe54,
XK_dead_breve: 0xfe55,
XK_dead_abovedot: 0xfe56,
XK_dead_diaeresis: 0xfe57,
XK_dead_abovering: 0xfe58,
XK_dead_doubleacute: 0xfe59,
XK_dead_caron: 0xfe5a,
XK_dead_cedilla: 0xfe5b,
XK_dead_ogonek: 0xfe5c,
XK_dead_iota: 0xfe5d,
XK_dead_voiced_sound: 0xfe5e,
XK_dead_semivoiced_sound: 0xfe5f,
XK_dead_belowdot: 0xfe60,
XK_dead_hook: 0xfe61,
XK_dead_horn: 0xfe62,
XK_dead_stroke: 0xfe63,
XK_dead_abovecomma: 0xfe64,
XK_dead_psili: 0xfe64, /* non-deprecated alias for dead_abovecomma */
XK_dead_abovereversedcomma: 0xfe65,
XK_dead_dasia: 0xfe65, /* non-deprecated alias for dead_abovereversedcomma */
XK_dead_doublegrave: 0xfe66,
XK_dead_belowring: 0xfe67,
XK_dead_belowmacron: 0xfe68,
XK_dead_belowcircumflex: 0xfe69,
XK_dead_belowtilde: 0xfe6a,
XK_dead_belowbreve: 0xfe6b,
XK_dead_belowdiaeresis: 0xfe6c,
XK_dead_invertedbreve: 0xfe6d,
XK_dead_belowcomma: 0xfe6e,
XK_dead_currency: 0xfe6f,

XK_VoidSymbol: 0xffffff, /* Void symbol */

XK_BackSpace: 0xff08, /* Back space, back char */
Expand Down
32 changes: 32 additions & 0 deletions core/input/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ export function getKeysym(evt) {
return DOMKeyTable[key][location];
}

if(key === "Dead" ){
return getDeadKeysym(evt);
}

// Now we need to look at the Unicode symbol instead

// Special key? (FIXME: Should have been caught earlier)
Expand All @@ -189,3 +193,31 @@ export function getKeysym(evt) {

return null;
}

// Try to guess Keysym for Dead key. For now only should work for US-int
// TODO test
// TODO try to find and implement Dead keys for more keyboard layouts
export function getDeadKeysym(evt) {
switch(evt.code){
case "Quote":
if (evt.shiftKey){
return KeyTable.XK_dead_diaeresis //
} else {
return KeyTable.XK_dead_acute // ´
}
case "Backquote":
if (evt.shiftKey){
return KeyTable.XK_dead_grave
} else {
return KeyTable.XK_dead_tilde
}
case 'Digit6':
if (evt.shiftKey){
return KeyTable.XK_dead_circumflex
}

default:
console.log(evt)
return null
}
}

0 comments on commit 77f74e3

Please sign in to comment.