Skip to content

Add Keyboard Shortcuts to Chrome Extension #17

@Zweihander-Main

Description

@Zweihander-Main

Request:
It would be great if you could navigate using keyboard shortcuts on the Chrome new tab page. This would allow a generally faster workflow particularly when completing a lot of small tasks or 'neverminding' a lot of tasks at the end of the day.

Potential Problem:
When you open a new tab in Chrome, the DOM isn't usually selected so keyboard shortcuts wouldn't work. However, there's usually a way to select the DOM of the new tab extension -- tab, double tapping tab, double tapping F6, triple tapping F6 (if the bookmarks bar is open), possibly Control-Tab on OSX, ect.

Sample code:
Just looking through the installed extension code, the following on complice_newtabpage.js replacing the keypress event listener would do it:

document.addEventListener('keydown', function(e) {
  //keypress is deprecated and may not be os-agnostic
  if (!e.repeat) {
    switch (e.key) {// keyCode and which are deprecated
      case 'Enter':
        var match = text.match(linkRegex);
        if (match && match[0]) { //stops error when no link present
          window.open(match[0], '_self');
        }
        break;
      case ' ':
        $donebtn.click();
        break;
      case '%':
        $nevermindbtn.click();
        break;
      case 'J':
        document.getElementById('deferNextbtn').click();
        break;
      case 'L':
        document.getElementById('deferLastbtn').click();
        break;
    }
  }
});

Would be happy to put this in a pull request.

Other ideas:

  • Adding in '?' functionality from Complice to show these shortcuts
  • Adding in a shortcut to open the today page ('g t')
  • Adding in shortcuts to open other pages ('g e', 'g g', 'g r', 'g s')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions