index.js
function unregister(win, accelerator) {
	let wc;
	if (typeof accelerator === 'undefined') {
		wc = ANY_WINDOW;
		accelerator = win;
	} else {
		if (win.isDestroyed()) {
			debug(`Early return because window is destroyed.`);
			return;
		}
		wc = win.webContents;
	}
	if (Array.isArray(accelerator) === true) {
		accelerator.forEach(accelerator => {
			if (typeof accelerator === 'string') {
				unregister(win, accelerator);
			}
		});
		return;
	}

	debug(`Unregistering callback for ${accelerator} on window ${title(win)}`);

	_checkAccelerator(accelerator);

	debug(`${accelerator} seems a valid shortcut sequence.`);

	if (!windowsWithShortcuts.has(wc)) {
		debug(`Early return because window has never had shortcuts registered.`);
		return;
	}

	const shortcutsOfWindow = windowsWithShortcuts.get(wc);

	const eventStamp = toKeyEvent(accelerator);
	const shortcutIdx = _findShortcut(eventStamp, shortcutsOfWindow);
	if (shortcutIdx === -1) {
		return;
	}

	shortcutsOfWindow.splice(shortcutIdx, 1);

	// If the window has no more shortcuts,
	// we remove it early from the WeakMap
	// and unregistering the event listener
	if (shortcutsOfWindow.length === 0) {
		// Remove listener from window
		shortcutsOfWindow.removeListener();

		// Remove window from shortcuts catalog
		windowsWithShortcuts.delete(wc);
	}
}
function unregister(win, accelerator) {
	let wc;
	if (typeof accelerator === 'undefined') {
		wc = ANY_WINDOW;
		accelerator = win;
	} else {
		if (win.isDestroyed()) {
			debug(`Early return because window is destroyed.`);
			return;
		}
		wc = win.webContents;
	}
	if (Array.isArray(accelerator) === true) {
		accelerator.forEach(accelerator => {
			if (typeof accelerator === 'string') {
				unregister(win, accelerator);
			}
		});
		return;
	}

	debug(`Unregistering callback for ${accelerator} on window ${title(win)}`);

	_checkAccelerator(accelerator);

	debug(`${accelerator} seems a valid shortcut sequence.`);

	if (!windowsWithShortcuts.has(wc)) {
		debug(`Early return because window has never had shortcuts registered.`);
		return;
	}

	const shortcutsOfWindow = windowsWithShortcuts.get(wc);

	const eventStamp = toKeyEvent(accelerator);
	const shortcutIdx = _findShortcut(eventStamp, shortcutsOfWindow);
	if (shortcutIdx === -1) {
		return;
	}

	shortcutsOfWindow.splice(shortcutIdx, 1);

	// If the window has no more shortcuts,
	// we remove it early from the WeakMap
	// and unregistering the event listener
	if (shortcutsOfWindow.length === 0) {
		// Remove listener from window
		shortcutsOfWindow.removeListener();

		// Remove window from shortcuts catalog
		windowsWithShortcuts.delete(wc);
	}
}
function unregister ( win , accelerator ) { let wc ; if ( typeof accelerator === 'undefined' ) { wc = ANY_WINDOW ; accelerator = win ; } else { if ( win . isDestroyed ( ) ) { debug ( ` ` ) ; return ; } wc = win . webContents ; } if ( Array . isArray ( accelerator ) === true ) { accelerator . forEach ( accelerator => { if ( typeof accelerator === 'string' ) { unregister ( win , accelerator ) ; } } ) ; return ; } debug ( ` ${ accelerator } ${ title ( win ) } ` ) ; _checkAccelerator ( accelerator ) ; debug ( ` ${ accelerator } ` ) ; if ( ! windowsWithShortcuts . has ( wc ) ) { debug ( ` ` ) ; return ; } const shortcutsOfWindow = windowsWithShortcuts . get ( wc ) ; const eventStamp = toKeyEvent ( accelerator ) ; const shortcutIdx = _findShortcut ( eventStamp , shortcutsOfWindow ) ; if ( shortcutIdx === - 1 ) { return ; } shortcutsOfWindow . splice ( shortcutIdx , 1 ) ; // If the window has no more shortcuts, // we remove it early from the WeakMap // and unregistering the event listener if ( shortcutsOfWindow . length === 0 ) { // Remove listener from window shortcutsOfWindow . removeListener ( ) ; // Remove window from shortcuts catalog windowsWithShortcuts . delete ( wc ) ; } }
Unregisters the shortcut of `accelerator` registered on the BrowserWindow instance.
@param  {BrowserWindow} win - BrowserWindow instance to unregister.
This argument could be omitted, in this case the function unregister the shortcut
on all app windows. If you registered the shortcut on a particular window instance, it will do nothing.
@param  {String|Array<String>} accelerator - the shortcut to unregister
@return {Undefined}
Unregisters the shortcut of accelerator registered on the BrowserWindow instance .