I use the win/os key in most of my other applications. I dislike having to edit the pref.js directly to get it to work in firefox and thunderbird. I usually screw something up. So I finally made the effort and looked at how to add support for using the win/osKey in keyconfig.
It was suprisingly easy to figure out without the help of the alert function and the error console. The hardest part was the keycode and the use of getModifierState.
Based on the keycodes listed at
https://developer.mozilla.org/en-US/doc ... nt.keyCodethis should work on Windows and Unix.
The only file I changed is in keyconfig.xpi/keyconfig.zip/content/keyconfig.js
Or
The diff is
Code: Select all
--- keyconfig.js.orig 2014-12-19 09:30:34.202091007 -0500
+++ keyconfig.js.new 2014-12-19 09:39:03.544662036 -0500
@@ -32,10 +32,14 @@
gPlatformKeys.alt = platformKeys.getString("VK_ALT");
gPlatformKeys.ctrl = platformKeys.getString("VK_CONTROL");
gPlatformKeys.sep = platformKeys.getString("MODIFIER_SEPARATOR");
+ gPlatformKeys.win = platformKeys.getString("VK_WIN");
+
+
switch (gPrefService.getIntPref("ui.key.accelKey")){
case 17: gPlatformKeys.accel = gPlatformKeys.ctrl; break;
case 18: gPlatformKeys.accel = gPlatformKeys.alt; break;
case 224: gPlatformKeys.accel = gPlatformKeys.meta; break;
+ case 91: gPlatformKeys.accel = gPlatformKeys.win; break;
default: gPlatformKeys.accel = (window.navigator.platform.search("Mac") == 0 ? gPlatformKeys.meta : gPlatformKeys.ctrl);
}
@@ -102,7 +106,7 @@
function onOK() { }
function getFormattedKey(modifiers,key,keycode) {
- if(modifiers == "shift,alt,control,accel" && keycode == "VK_SCROLL_LOCK") return gStrings.disabled;
+ if(modifiers == "shift,alt,control,accel,os" && keycode == "VK_SCROLL_LOCK") return gStrings.disabled;
if(!key && !keycode) return gStrings.disabled;
var val = "";
@@ -112,6 +116,7 @@
.replace("shift",gPlatformKeys.shift)
.replace("control",gPlatformKeys.ctrl)
.replace("meta",gPlatformKeys.meta)
+ .replace("os",gPlatformKeys.win)
.replace("accel",gPlatformKeys.accel)
+gPlatformKeys.sep;
if(key == " ") {
@@ -179,13 +184,13 @@
if(event.ctrlKey) modifiers.push("control");
if(event.metaKey) modifiers.push("meta");
if(event.shiftKey) modifiers.push("shift");
+ if(event.getModifierState("OS")) modifiers.push("os");
modifiers = modifiers.join(" ");
var key = null; var keycode = null;
if(event.charCode) key = String.fromCharCode(event.charCode).toUpperCase();
else { keycode = gVKNames[event.keyCode]; if(!keycode) return;}
-
gEdit.value = getFormattedKey(modifiers,key,keycode);
gEdit.keys = [modifiers,key,keycode];