title: Disable DevTools on nwjs 13
body: <p>We're developing an app based on Chrome Apps with NWJS 0.13.0 Alpha version, because lower versions don't support Chrome Apps. We need version 13 so we can use Serial Ports.</p>
  <p>However in Windows or Ubuntu, when pressing right clic it showed a menu which I disabled (because it was specified that way) with the following function in all of my HTML's:</p>
  <pre><code>&lt;body oncontextmenu=&quot;return false&quot;&gt;
  &lt;script language=&quot;javascript&quot;&gt;
      document.onmousedown=disableclick;
      function disableclick(event) {
          if(event.button==2) {
              return false;
          }
      }
  &lt;/script&gt;
  </code></pre>
  <p>But in Mac OS X we had another problem because of a custom menu, after reading the <a href="https://github.com/nwjs/nw.js/wiki/manifest-format" rel="noreferrer">Manifest Format</a> I found that on my <code>package.json</code> file I needed to add <code>&quot;no-edit-menu&quot;: false</code> attribute and that menu doesn't show anymore, the <code>package.json</code> file is the following:</p>
  <pre><code>{
      &quot;main&quot;: &quot;main.html&quot;,
      &quot;name&quot;: &quot;PAGUSS&quot;,
      &quot;description&quot;: &quot;Paguss Payment Services&quot;,
      &quot;version&quot;: &quot;0.1.0&quot;,
      &quot;keywords&quot;: [ &quot;paguss&quot;, &quot;payment&quot; ],
      &quot;window&quot;: {
          &quot;title&quot;: &quot;Paguss&quot;,
          &quot;transparent&quot;: true,
          &quot;icon&quot;: &quot;assets/images/64x64.png&quot;,
          &quot;toolbar&quot;: false,
          &quot;frame&quot;: true,
          &quot;resizable&quot;: true,
          &quot;position&quot;: &quot;mouse&quot;,
          &quot;min_width&quot;: 400,
          &quot;min_height&quot;: 500,
          &quot;max_width&quot;: 1200,
          &quot;max_height&quot;: 800,
          &quot;no-edit-menu&quot;: false
      },
      &quot;webkit&quot;: {
          &quot;plugin&quot;: false
      }
  }
  </code></pre>
  <p>Now, I tried to change <code>&quot;toolbar&quot;: false,</code> on the <code>package.json</code> file so there's no toolbar and thus user can't open devtools from there, but if they press <code>F12</code> or <code>Shift-Ctrl-J</code> they're still able to open devtools window. I also tried the following line in my above script in an attempt to try to disable devtools window to open without success (at least on Mac OS X where it's our priority to disable it):</p>
  <pre><code>if(event.button==2 || window.event.keycode==123 || (window.event.keycode==55 &amp;&amp; window.event.keycode==58 &amp;&amp; window.event.keycode==34)) {
      return false;
  }
  </code></pre>
  <p>I got the above key codes from <a href="http://macbiblioblog.blogspot.mx/2014/12/key-codes-for-function-and-special-keys.html" rel="noreferrer">here</a> for Apple's keyboard.</p>
  <p>I'm really new into Javascript coding so probably some of my attempts aren't right or close to be right.</p>
  <p>Is there any way to disable dev tools from opening on NWJS 13 on any OS?</p>
  <hr />
  <h1>Edit</h1>
  <p>I found there was an error on my 2nd attempt with keyCodes.</p>
  <p>I was trying to call the script on right click event, I changed the code as:</p>
  <pre><code>&lt;script language=&quot;javascript&quot;&gt;
      document.onmousedown=disableclick;
      document.onkeydown=disableconsole;
      function disableclick(event) {
          if(event.button==2) {
              return false;    
          }
      }
      function disableconsole(event) {
          if (event.keyCode==123) {
              return false;
          }
      }
  &lt;/script&gt;
  </code></pre>
  <p>Which actually prevents the console from opening dev tools using <code>F12</code> key on Linux, however Windows and OS X are still not working even with this update.</p>
  <h2>Edit 2</h2>
  <p>I've found that there are different keyCodes for the different OS as seen on this <a href="https://gist.github.com/willwade/5330474" rel="noreferrer">table</a> so I guess I haven't got a successful response while testing on Windows and OS X because of it.</p>