CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-electron-debug

Adds useful debug features to your Electron app

86

1.19x
Overview
Eval results
Files

task.mdevals/scenario-9/

Window-Specific Keyboard Shortcuts

Build an Electron application module that manages window-specific keyboard shortcuts. The module should allow registering different keyboard shortcuts for individual windows without those shortcuts interfering with other windows or system-wide shortcuts.

Capabilities

Register Window-Specific Shortcuts

Register keyboard shortcuts that only work when a specific window has focus.

  • Registering 'Ctrl+R' on window A and 'Ctrl+T' on window B allows both shortcuts to work on their respective windows @test
  • When window A has focus, pressing 'Ctrl+R' triggers the callback for window A only @test

Support Same Shortcuts on Different Windows

Multiple windows can have the same accelerator without conflicts.

  • Two different windows can register the same 'F5' accelerator and each triggers only when that window has focus @test

Unregister Shortcuts

Clean up shortcuts when windows are closed or when explicitly requested.

  • When a window is closed, unregisterAll removes all shortcuts for that window @test

Implementation

@generates

API

/**
 * Register a keyboard shortcut for a specific window
 * @param {BrowserWindow} window - The Electron window to register the shortcut for
 * @param {string} accelerator - The keyboard shortcut (e.g., 'Ctrl+R', 'F5')
 * @param {Function} callback - Function to call when shortcut is triggered
 */
function registerShortcut(window, accelerator, callback) {}

/**
 * Unregister a specific shortcut for a window
 * @param {BrowserWindow} window - The Electron window
 * @param {string} accelerator - The keyboard shortcut to remove
 */
function unregisterShortcut(window, accelerator) {}

/**
 * Unregister all shortcuts for a specific window
 * @param {BrowserWindow} window - The Electron window
 */
function unregisterAll(window) {}

module.exports = {
  registerShortcut,
  unregisterShortcut,
  unregisterAll
};

Dependencies { .dependencies }

electron-localshortcut { .dependency }

Provides window-specific keyboard shortcut registration that works independently per window without interfering with global shortcuts.

electron { .dependency }

Provides the Electron BrowserWindow API for window management.

Install with Tessl CLI

npx tessl i tessl/npm-electron-debug

tile.json