Skip to content

Commit

Permalink
Set the period as the hotkey to make a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
carbon-steel committed Jun 30, 2017
1 parent d9504f6 commit b160a03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
6 changes: 6 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ function handleTabSwitch(hotkey_info, overrideDeduplicate){
);
}

function openNewTab(){
chrome.tabs.create({});
}

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
// Hold key event (pressed or released); broadcast to all tabs.
Expand Down Expand Up @@ -322,6 +325,9 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
else if (hotkey == NAV_PREVIOUS_KEYVAL) {
navigateToPreviousTab();
}
else if (hotkey == TAB_NEW_KEYVAL) {
openNewTab();
}
else {
var normalized = hotkey.toLowerCase();
var overrideDeduplicate = hotkey != normalized;
Expand Down
12 changes: 1 addition & 11 deletions hotkeys.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
var BUILT_IN_HOTKEYS = [
NAV_LEFT_KEYVAL,
NAV_RIGHT_KEYVAL,
MOVE_LEFT_KEYVAL,
MOVE_RIGHT_KEYVAL,
TAB_CLOSE_KEYVAL,
TAB_SEARCH_KEYVAL,
NAV_PREVIOUS_KEYVAL
];

// Global state.
// This gets updated by reading from storage before key event handlers are
// attached. See bottom.
Expand Down Expand Up @@ -37,7 +27,7 @@ function keydownHandler(e) {
if (e.key.length == 1 &&
65 <= ascii_value && ascii_value <= 90 ||
97 <= ascii_value && ascii_value <= 122) {
hotkey += e.key;
hotkey += e.key;
}
// Capture built-in hotkeys. Send them immediately so that the user can
// repeatedly use them without releasing the hold key.
Expand Down
13 changes: 13 additions & 0 deletions shared_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ var MOVE_LEFT_KEYVAL = "{";
var MOVE_RIGHT_KEYVAL = "}";
var TAB_CLOSE_KEYVAL = ";";
var TAB_SEARCH_KEYVAL = "/";
var TAB_NEW_KEYVAL = ".";
var NAV_PREVIOUS_KEYVAL = " ";

var BUILT_IN_HOTKEYS = [
NAV_LEFT_KEYVAL,
NAV_RIGHT_KEYVAL,
MOVE_LEFT_KEYVAL,
MOVE_RIGHT_KEYVAL,
TAB_CLOSE_KEYVAL,
TAB_SEARCH_KEYVAL,
NAV_PREVIOUS_KEYVAL,
TAB_NEW_KEYVAL
];

// For tab search page.
var ENTER_KEYVAL = "Enter";
var ARROW_UP_KEYVAL = "ArrowUp";
Expand Down

0 comments on commit b160a03

Please sign in to comment.