Modal Keys Remapper

pending

by Naoki Mizuno

Customize keyboard shortcuts for navigating modal dialogs and suggestion lists.

2 starsUpdated 3mo agoMITDiscovered via Obsidian Unofficial Plugins
View on GitHub

Modal Keys Remapper

An Obsidian plugin that allows you to customize keyboard shortcuts for navigating modal dialogs and suggestion lists.

Features

  • Customizable Navigation Keys: Remap keys for moving up/down in modal selections (default: Ctrl+n/Ctrl+p)
  • Modal Confirm/Close Shortcut: Configure custom keys to confirm/close in modals (default: Obsidian default)
  • Target Specific Elements: Define which CSS classes trigger the custom keybindings
  • Multiple Keyboard Shortcuts: Configure multiple shortcuts for each action (up to 10 per action)

Default Keybindings

  • Next (Move Down): Ctrl+n → Arrow Down
  • Previous (Move Up): Ctrl+p → Arrow Up
  • Confirm: not set → Uses Obsidian default (Enter) to confirm/accept in modal
  • Close Modal: not set → Uses Obsidian default (Escape) to close modal

Note About Explicitly Setting the Confirm/Close Shortcuts

You may observe some issues when you explicitly set the confirm/close shortcuts to the Obsidian default keys (e.g., Enter for confirm, and Escape for close) and set a target that makes the shortcut effective in the editor (e.g., .app-container or .cm-editor). In this case, the key is processed twice (once by the Obsidian app, and once more due to this plugin sending the Enter key event), resulting in two lines added from a single Enter key press.

In short, it is recommended to only set shortcuts that you would like to use and leave unused actions unset.

Settings

Navigate to Settings → Modal Keys Remapper to customize:

  1. Navigation Keys:
    • Click "Record" next to each shortcut and press your desired key combination
    • Add multiple shortcuts by clicking the "+" button (appears when all shortcuts are set)
    • Remove shortcuts by clicking the "−" icon (clears value when only one exists, removes when multiple exist)
    • Each action supports up to 10 shortcuts
  2. Target CSS Classes: Specify which modal elements should respond to your custom keys (one per line)
    • Default: .suggestion-container and .modal-container

Notes:

  • Hotkeys take precedence over this plugin's settings.
  • Duplicate keys are removed automatically.

How It Works

The plugin listens for keyboard events when specific modal elements are present in the DOM. When you press a configured key combination, it dispatches the corresponding arrow key, enter key, or escape key event to navigate, confirm, or close in the modal.

If you would like to add more elements for the shortcut to be effective in, open the developer tool (Ctrl+Shift+i or Cmd+Shift+i) to find the class name, then append that in the Target CSS classes setting.

Installation

From Obsidian Community Plugins

  1. Open Settings in Obsidian
  2. Navigate to Community plugins and disable Safe mode
  3. Click Browse and search for "Modal Keys Remapper"
  4. Click Install and then Enable

Manual Installation

  1. Download the latest release from the releases page
  2. Extract the files to your vault's plugins folder: <vault>/.obsidian/plugins/obsidian-modal-keys/
  3. Reload Obsidian
  4. Enable the plugin in Settings → Community plugins

Development

Setup

# Clone the repository
git clone https://github.com/naoki-mizuno/obsidian-modal-keys.git

# Install dependencies
npm install

# Start development build (watch mode)
npm run dev

Building

# Production build
npm run build

For development, you can also place the repository folder directly in your vault's .obsidian/plugins/ folder and run npm run dev to automatically rebuild on changes.

Credits

This plugin is largely based on obsidian-command-palette-keys and the discussion at the Obsidian forum.

License

MIT License - see LICENSE for details.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.