Skip to content

Commit

Permalink
better keypad/numpad handling: detect numlock state and only use KP_*…
Browse files Browse the repository at this point in the history
… keysyms for numpad arrows, detect numlock state based on the key string we send for that numpad keyname

git-svn-id: https://xpra.org/svn/Xpra/trunk@15515 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 4, 2017
1 parent 4379242 commit cfbcb28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 9 additions & 1 deletion src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,15 @@ XpraClient.prototype._keyb_process = function(pressed, event) {
}

var key_language = null;
//special case for numpad,
//try to distinguish arrowpad and numpad:
//(for arrowpad, keyname==str)
if (keyname!=str && str in NUMPAD_TO_NAME) {
keyname = NUMPAD_TO_NAME[str];
this.num_lock = ("0123456789.".indexOf(keyname))>=0;
}
//some special keys are better mapped by name:
if (keyname in KEY_TO_NAME){
else if (keyname in KEY_TO_NAME){
keyname = KEY_TO_NAME[keyname];
}
//next try mapping the actual character
Expand Down Expand Up @@ -591,6 +598,7 @@ XpraClient.prototype._keyb_process = function(pressed, event) {
//send via a timer so we get a chance to capture the clipboard value,
//before we send control-V to the server:
var packet = ["key-action", this.topwindow, keyname, pressed, modifiers, keyval, str, keycode, group];
console.debug(packet);
var me = this;
setTimeout(function () {
//show("win="+win.toSource()+", keycode="+keycode+", modifiers=["+modifiers+"], str="+str);
Expand Down
18 changes: 10 additions & 8 deletions src/html5/js/Keycodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,17 @@ KEY_TO_NAME = {
//special keys:
"ScrollLock" : "Scroll_Lock",
"Pause" : "Pause",
//Num pad:
"NumLock" : "Num_Lock",
//Arrow pad:
"Insert" : "Insert",
"Home" : "Home",
"PageUp" : "Prior",
"Delete" : "Delete",
"End" : "End",
"PageDown" : "Next",
};
NUMPAD_TO_NAME = {
//Num pad:
"NumpadDivide" : "KP_Divide",
"NumpadMultiply" : "KP_Multiply",
"NumpadSubstract" : "KP_Substract",
Expand All @@ -48,13 +57,6 @@ KEY_TO_NAME = {
"Home" : "KP_Home",
"ArrowUp" : "KP_Up",
"PageUp" : "KP_Prior",
//Arrow pad:
//"Insert" : "KP_Insert", //dupe of numpad
//"Home" : "KP_Home", //dupe of numpad
//"PageUp" : "Prior", //dupe of numpad (with a different mapping..)
"Delete" : "Delete",
//"End" : "End", //dupe of numpad (with a different mapping..)
//"PageDown" : "Next",
};
for (var i=0; i<=9; i++) {
KEY_TO_NAME["Numpad"+i] = ""+i;
Expand Down

0 comments on commit cfbcb28

Please sign in to comment.