in suite/chatzilla/content/handlers.js [570:721]
function onWindowKeyPress(e) {
var code = Number(e.keyCode);
var w;
var newOfs;
var userList = document.getElementById("user-list");
var elemFocused = document.commandDispatcher.focusedElement;
const isMac = client.platform == "Mac";
const isLinux = client.platform == "Linux";
const isWindows = client.platform == "Windows";
const isOS2 = client.platform == "OS/2";
const isUnknown = !(isMac || isLinux || isWindows || isOS2);
switch (code) {
case 9 /* Tab */:
// Control-Tab => next tab (all platforms)
// Control-Shift-Tab => previous tab (all platforms)
if (e.ctrlKey && !e.altKey && !e.metaKey) {
cycleView(e.shiftKey ? -1 : 1);
e.preventDefault();
}
break;
case 33: /* Page Up */
case 34 /* Page Down */:
// Control-Page Up => previous tab (all platforms)
// Control-Page Down => next tab (all platforms)
if (
(e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey) ||
(e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey)
) {
cycleView(2 * code - 67);
e.preventDefault();
break;
}
if (
!e.ctrlKey &&
!e.altKey &&
!e.metaKey &&
!e.shiftKey &&
elemFocused != userList
) {
w = client.currentFrame;
newOfs = w.pageYOffset + w.innerHeight * 0.75 * (2 * code - 67);
if (newOfs > 0) {
w.scrollTo(w.pageXOffset, newOfs);
} else {
w.scrollTo(w.pageXOffset, 0);
}
e.preventDefault();
}
break;
case 37: /* Left Arrow */
case 39 /* Right Arrow */:
// Command-Alt-Left Arrow => previous tab (Mac only)
// Command-Alt-Right Arrow => next tab (Mac only)
if (isMac && e.metaKey && e.altKey && !e.ctrlKey && !e.shiftKey) {
cycleView(code - 38);
e.preventDefault();
}
break;
case 219: /* [ */
case 221 /* ] */:
// Command-Shift-[ => previous tab (Mac only)
// Command-Shift-] => next tab (Mac only)
if (isMac && e.metaKey && e.shiftKey && !e.altKey && !e.ctrlKey) {
cycleView(code - 220);
e.preventDefault();
}
break;
case 117 /* F6 */:
// F6 => focus next (all platforms)
// Shift-F6 => focus previous (all platforms)
if (!e.altKey && !e.ctrlKey && !e.metaKey) {
advanceKeyboardFocus(e.shiftKey ? -1 : 1);
e.preventDefault();
}
break;
}
// Code is zero if we have a typeable character triggering the event.
if (code != 0) {
return;
}
// OS X only: Command-{ and Command-}
// Newer geckos seem to only provide these keys in charCode, not keyCode
if (isMac && e.metaKey && e.shiftKey && !e.altKey && !e.ctrlKey) {
if (e.charCode == 123 || e.charCode == 125) {
cycleView(e.charCode - 124);
e.preventDefault();
return;
}
}
// Numeric shortcuts
// The following code is copied from:
// /mozilla/browser/base/content/browser.js
// Revision: 1.748
// Lines: 1397-1421
// \d in a RegExp will find any Unicode character with the "decimal digit"
// property (Nd)
var regExp = /\d/;
if (!regExp.test(String.fromCharCode(e.charCode))) {
return;
}
// Some Unicode decimal digits are in the range U+xxx0 - U+xxx9 and some are
// in the range U+xxx6 - U+xxxF. Find the digit 1 corresponding to our
// character.
var digit1 = (e.charCode & 0xfff0) | 1;
if (!regExp.test(String.fromCharCode(digit1))) {
digit1 += 6;
}
var idx = e.charCode - digit1;
if (0 <= idx && idx <= 8) {
var modifier =
(e.altKey ? 0x1 : 0) |
(e.ctrlKey ? 0x2 : 0) |
(e.shiftKey ? 0x4 : 0) |
(e.metaKey ? 0x8 : 0);
var modifierMask;
if (client.prefs.tabGotoKeyModifiers) {
modifierMask = client.prefs.tabGotoKeyModifiers;
} else {
modifierMask = 0x1;
} // alt
if ((modifier & modifierMask) == modifierMask) {
// Pressing 1-8 takes you to that tab, while pressing 9 takes you
// to the last tab always.
if (idx == 8) {
idx = client.viewsArray.length - 1;
}
if (idx in client.viewsArray && client.viewsArray[idx].source) {
var newView = client.viewsArray[idx].source;
dispatch("set-current-view", { view: newView });
}
e.preventDefault();
}
}
}