<ul dir="auto">
<li>Electron version: 1.3.5</li>
<li>Operating system: Windows 10</li>
</ul>
<p dir="auto">It seems like certain menu accelerators don't work when the app is running in Windows, but they do work in macOS. In the example below, none of the accelerators work in Windows, but clicking the menu item does log the correct message. But <code class="notranslate">CmdOrCtrl+B</code> <em>does</em> work in Windows.</p>
<p dir="auto">Here's the code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const electron = require('electron');
const app = electron.app;
const Menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
app.on('ready', function() {
    let mainWindow = new BrowserWindow({width: 800, height: 600});
    mainWindow.loadURL(`file://${__dirname}/index.html`);

    let menu = Menu.buildFromTemplate([
        {
            label: 'Edit',
            submenu: [
                {
                    label: 'Cut',
                    accelerator: 'CmdOrCtrl+X',
                    click: () =&gt; console.log('cut'),
                },
                {
                    label: 'Copy',
                    accelerator: 'CmdOrCtrl+C',
                    click: () =&gt; console.log('copy'),
                },
                {
                    label: 'Paste',
                    accelerator: 'CmdOrCtrl+V',
                    click: () =&gt; console.log('paste'),
                },
                {
                    label: 'Select All',
                    accelerator: 'CmdOrCtrl+A',
                    click: () =&gt; console.log('select all'),
                },
            ],
        },
    ]);
    Menu.setApplicationMenu(menu);
});
app.on('window-all-closed', function() {
    app.quit();
});"><pre class="notranslate"><code class="notranslate">const electron = require('electron');
const app = electron.app;
const Menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
app.on('ready', function() {
    let mainWindow = new BrowserWindow({width: 800, height: 600});
    mainWindow.loadURL(`file://${__dirname}/index.html`);

    let menu = Menu.buildFromTemplate([
        {
            label: 'Edit',
            submenu: [
                {
                    label: 'Cut',
                    accelerator: 'CmdOrCtrl+X',
                    click: () =&gt; console.log('cut'),
                },
                {
                    label: 'Copy',
                    accelerator: 'CmdOrCtrl+C',
                    click: () =&gt; console.log('copy'),
                },
                {
                    label: 'Paste',
                    accelerator: 'CmdOrCtrl+V',
                    click: () =&gt; console.log('paste'),
                },
                {
                    label: 'Select All',
                    accelerator: 'CmdOrCtrl+A',
                    click: () =&gt; console.log('select all'),
                },
            ],
        },
    ]);
    Menu.setApplicationMenu(menu);
});
app.on('window-all-closed', function() {
    app.quit();
});
</code></pre></div>
<ul dir="auto">
<li>Electron version: All</li>
<li>Operating system: Windows vs Mac</li>
</ul>
<p dir="auto">When I define a custom undo behaviour I found it become different between Windows and Mac devices.</p>
<p dir="auto">This is what I did:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// the main menu I overwrite:
let menuTemplate = [
  // Edit
  {
    label: 'Edit',
    submenu: [
      {
        label: 'Undo',
        accelerator: 'CmdOrCtrl+Z',
        click () {
          console.log('Undo');
        }
      },

      {
        label: 'Redo',
        accelerator: 'Shift+CmdOrCtrl+Z',
        click () {
          console.log('Redo');
        }
      },
    ]
  }
];"><pre class="notranslate"><span class="pl-c">// the main menu I overwrite:</span>
<span class="pl-k">let</span> <span class="pl-s1">menuTemplate</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span>
  <span class="pl-c">// Edit</span>
  <span class="pl-kos">{</span>
    <span class="pl-c1">label</span>: <span class="pl-s">'Edit'</span><span class="pl-kos">,</span>
    <span class="pl-c1">submenu</span>: <span class="pl-kos">[</span>
      <span class="pl-kos">{</span>
        <span class="pl-c1">label</span>: <span class="pl-s">'Undo'</span><span class="pl-kos">,</span>
        <span class="pl-c1">accelerator</span>: <span class="pl-s">'CmdOrCtrl+Z'</span><span class="pl-kos">,</span>
        <span class="pl-en">click</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
          <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'Undo'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>

      <span class="pl-kos">{</span>
        <span class="pl-c1">label</span>: <span class="pl-s">'Redo'</span><span class="pl-kos">,</span>
        <span class="pl-c1">accelerator</span>: <span class="pl-s">'Shift+CmdOrCtrl+Z'</span><span class="pl-kos">,</span>
        <span class="pl-en">click</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
          <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'Redo'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">]</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">]</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">As you can see, I overwrite the Undo behaviour and use the same shortcuts from the Browser. When I press <code class="notranslate">ctrl/cmd+z</code> on Mac, things goes fine, the menu click go first and take over it. But in Windows, it seems like the original <code class="notranslate">webContents.undo()</code> will be executed first, if the undo stack have states (which means you should typing some letters on a <code class="notranslate">&lt;input&gt;</code> first).</p>
<p dir="auto">This makes me have no chance to overwrite the undo for Windows platform. Is this expect in Windows? If we can not change the menu behaviour, is there a way to disable/stop <code class="notranslate">webContents.undo</code> when pressing <code class="notranslate">ctrl+z</code> so that the Main Menu can receive it?</p>