diff --git a/web/history.md b/web/history.md index c70dc43eab..7107aa29f6 100644 --- a/web/history.md +++ b/web/history.md @@ -11,6 +11,7 @@ * Added support for L/R Alt and Ctrl modifiers for keyboards. (#9) (#52) * Added support for use of the Caps Lock state within keyboards if specified by a keyboard designer. * Fixed next-layer processing (#116) +* Fixed key codes for longpress keys ## 2017-07-10 2.0.473 stable * 2.0 stable release build. diff --git a/web/source/kmwembedded.js b/web/source/kmwembedded.js index db935281e4..4fa4cc1323 100644 --- a/web/source/kmwembedded.js +++ b/web/source/kmwembedded.js @@ -437,6 +437,12 @@ // Define modifiers value for sending to keyboard mapping function Lkc.Lmodifiers = keyShiftState; + // Handles modifier states when the OSK is emulating rightalt through the leftctrl-leftalt layer. + if((Lkc.Lmodifiers & osk.modifierBitmasks['ALT_GR_SIM']) == osk.modifierBitmasks['ALT_GR_SIM'] && osk.emulatesAltGr()) { + Lkc.Lmodifiers &= ~osk.modifierBitmasks['ALT_GR_SIM']; + Lkc.Lmodifiers |= osk.modifierCodes['RALT']; + } + Lkc.vkCode=Lkc.Lcode; // Pass this key code and state to the keyboard program diff --git a/web/source/kmwosk.js b/web/source/kmwosk.js index e809e3c392..88dad2f095 100644 --- a/web/source/kmwosk.js +++ b/web/source/kmwosk.js @@ -744,7 +744,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) { if(keymanweb.isChiral()) { nextLayer = 'leftctrl-rightalt'; } else { - nextLayer = 'ctrlalt'; + nextLayer = 'ctrl-alt'; } break; case 'K_CURRENCIES': @@ -769,15 +769,15 @@ if(!window['tavultesoft']['keymanweb']['initialized']) { } /** - * Get the default key code from the virtual key code (physical keyboard mapping) + * Get the default key string from the virtual key code (physical keyboard mapping) * * @param {string} keyName * @param {number} n * @param {number} keyShiftState - * @return {number} + * @return {string} */ osk.defaultKeyOutput = function(keyName,n,keyShiftState) { - var ch = 0, checkCodes = false; + var ch = '', checkCodes = false; // check if exact match to SHIFT's code. Only the 'default' and 'shift' layers should have default key outputs. if(keyShiftState == 0) { @@ -791,12 +791,13 @@ if(!window['tavultesoft']['keymanweb']['initialized']) { // Test for fall back to U_xxxx key id - For this first test, we ignore the key code // and use the keyName - if((keyName.substr(0,2) == 'U_')) { - ch=String.fromCharCode(parseInt(keyName.substr(2,6),16)); - if(ch <= 32 || (ch > 127 && ch < 160)) { - // 127 - 160 refer to Unicode control codes. + if((keyName.substr(0,2) == 'U_')) { + var value = parseInt(keyName.substr(2,6), 16); + ch=String.fromCharCode(value); + if((value <= 31) || ((value >= 127) && (value <= 159))) { + // 0 - 31 and 127 - 159 refer to Unicode control codes. // Do not allow output of these codes via U_xxxx shortcuts. - ch = 0; + ch = ''; } // Hereafter, we refer to keycodes. } else if(checkCodes) { @@ -3098,7 +3099,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) { shiftKey['text']='*Ctrl*'; break; case 'alt': shiftKey['text']='*Alt*'; break; - case 'ctrlalt': + case 'ctrl-alt': shiftKey['text']='*AltGr*'; break; }; }