aboutsummaryrefslogtreecommitdiff
path: root/src/background/keys.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/keys.js')
-rw-r--r--src/background/keys.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/background/keys.js b/src/background/keys.js
new file mode 100644
index 0000000..0ce53fa
--- /dev/null
+++ b/src/background/keys.js
@@ -0,0 +1,57 @@
+import actions from '../actions';
+
+const defaultKeymap = {
+ ':': { type: actions.CMD_OPEN },
+ 'o': { type: actions.CMD_TABS_OPEN, alter: false },
+ 'O': { type: actions.CMD_TABS_OPEN, alter: true },
+ 'b': { type: actions.CMD_BUFFER },
+ 'k': { type: actions.SCROLL_LINES, count: -1 },
+ 'j': { type: actions.SCROLL_LINES, count: 1 },
+ '<C-E>': { type: actions.SCROLL_LINES, count: -1 },
+ '<C-Y>': { type: actions.SCROLL_LINES, count: 1 },
+ '<C-U>': { type: actions.SCROLL_PAGES, count: -0.5 },
+ '<C-D>': { type: actions.SCROLL_PAGES, count: 0.5 },
+ '<C-B>': { type: actions.SCROLL_PAGES, count: -1 },
+ '<C-F>': { type: actions.SCROLL_PAGES, count: 1 },
+ 'gg': { type: actions.SCROLL_TOP },
+ 'G': { type: actions.SCROLL_BOTTOM },
+ '0': { type: actions.SCROLL_LEFT },
+ '$': { type: actions.SCROLL_RIGHT },
+ 'd': { type: actions.TABS_CLOSE },
+ 'u': { type: actions.TABS_REOPEN },
+ 'h': { type: actions.TABS_PREV, count: 1 },
+ 'l': { type: actions.TABS_NEXT, count: 1 },
+ 'r': { type: actions.TABS_RELOAD, cache: false },
+ 'R': { type: actions.TABS_RELOAD, cache: true },
+ 'zi': { type: actions.ZOOM_IN },
+ 'zo': { type: actions.ZOOM_OUT },
+ 'zz': { type: actions.ZOOM_NEUTRAL },
+ 'f': { type: actions.FOLLOW_START, newTab: false },
+ 'F': { type: actions.FOLLOW_START, newTab: true },
+ 'H': { type: actions.HISTORY_PREV },
+ 'L': { type: actions.HISTORY_NEXT },
+}
+
+const asKeymapChars = (keys) => {
+ return keys.map((k) => {
+ let c = String.fromCharCode(k.code);
+ if (k.ctrl) {
+ return '<C-' + c.toUpperCase() + '>';
+ } else {
+ return c
+ }
+ }).join('');
+}
+
+const asCaretChars = (keys) => {
+ return keys.map((k) => {
+ let c = String.fromCharCode(k.code);
+ if (k.ctrl) {
+ return '^' + c.toUpperCase();
+ } else {
+ return c;
+ }
+ }).join('');
+}
+
+export { defaultKeymap, asKeymapChars, asCaretChars };