Can I run custom JavaScript with Shortkeys?

Updated

Yes. Shortkeys lets you bind any JavaScript code to a keyboard shortcut, and it ships a full CodeMirror editor with syntax highlighting and the One Dark theme for writing that code. This is aimed at advanced users who want automation or page-specific actions that the built-in actions don't cover. If you'd rather not write code, the extension also includes 100+ built-in actions you can assign instead.

How custom JavaScript fits into Shortkeys

Shortkeys is a browser extension for Chrome and Firefox that maps keyboard shortcuts to actions. Those actions come from two sources:

  • Built-in actions — over 100 predefined behaviors across categories like scrolling, navigation, and tabs (for example, scroll to bottom, next tab, mute audio).
  • Custom JavaScript — you write the code yourself, and it runs when you press the assigned key combo.

The custom JavaScript option is what makes Shortkeys extensible: anything the built-in list doesn't do, you can implement in code and trigger from the keyboard.

What the editor gives you

When you configure a custom JavaScript shortcut, you're working in a CodeMirror editor rather than a plain text box. According to the site, that editor provides:

  • Syntax highlighting
  • The One Dark theme

In practice this means your script is readable and easier to debug than it would be in a bare textarea, which matters once a shortcut grows past a couple of lines.

How to set up a custom JavaScript shortcut

The general flow mirrors how Shortkeys handles any shortcut:

  1. Install the extension in Chrome or Firefox.
  2. Open the options page (the extension's settings, shown in the site as chrome-extension://shortkeys/options.html).
  3. Add a new shortcut and choose the custom JavaScript action rather than a built-in one.
  4. Write your code in the CodeMirror editor.
  5. Record your key combo — click Record and press the keys you want. Multi-key sequences like Vim's g g are supported.
  6. Save and test by pressing the shortcut on a page and checking that the expected behavior happens.

The site describes this as three steps — install, configure, execute — with configuration covering "pick an action or write custom JS, then record your key combo."

Where custom JavaScript is the right choice

Use custom JavaScript when:

  • You need a page-specific action that no built-in action covers.
  • You want to chain logic that depends on the page's content or state.
  • You're comfortable debugging in the browser console when something doesn't fire as expected.

Use built-in actions instead when a matching action already exists — scrolling, tab management, navigation, zoom, bookmarks, downloads, and video controls are all covered, so there's often no reason to write code.

Related features that pair well with custom scripts

  • Macros — chain multiple actions into a single shortcut, with delays between steps for precise automation.
  • Groups — organize shortcuts into collapsible groups you can enable, disable, or share as a unit.
  • Shortcut Packs — install curated collections (Vim, YouTube, GitHub, and others) with one click, useful as a starting point before you add your own scripts.
  • Command Palette — click the extension icon for a searchable list of all your active shortcuts.
  • Cloud Sync — shortcuts sync across your Chrome instances via your Google account.

Things to keep in mind

  • Custom JavaScript runs in the context of the page you're on, so a script written for one site may not behave the same elsewhere.
  • Multi-key sequences are supported, so shortcuts like g g won't collide with single-key bindings if you set them up deliberately.
  • The extension is described as free and open source, and the site notes it's trusted by 200,000+ Chrome users.

If your goal is quick automation without writing code, start with the built-in actions and Shortcut Packs; reach for custom JavaScript only when you hit something the built-in list can't do.