3

I'm building a node-webkit app, am listening for keypress events (in an angular directive).

Most combinations of keypress are working, but ctrl+f and ctrl+a are both not working.

This problem is specific to node-webkit. I've got the ctrl+a etc. working in the browser, but not in node-webkit.

I'm listening for keypress with the usual

document.bind('keypress',function...)

window.bind('keypress', function...)

window.bind('onkeypress', function...)

window.bind('keydown', function...)

any suggestions? Remember, the other combinations of keys ctrl+shift+o, etc. are working. As this is a node-webkit app, there is no browser based 'find' function, and I'm disabling the 'select all'.

Axifive
  • 1,159
  • 2
  • 19
  • 31
pedalpete
  • 21,076
  • 45
  • 128
  • 239

2 Answers2

0

Isn't it an answer you where looking for?

There is a fiddle in answer of ctrl+f. If you replace 70 to 65 in this example, it will also work for ctrl+a.

document.onkeydown = function (e) {

    /// check ctrl + f key
    if (e.ctrlKey === true && e.keyCode === 70/*65*/) {
        e.preventDefault();

        console.log('Ctrl + f was hit...');

        return false;
    }
}
Community
  • 1
  • 1
Andrew Shustariov
  • 2,530
  • 1
  • 17
  • 17
  • This is specific to node-webkit. Even if I don't look for e.ctrlKey and just console.log(e) on ctrl-a, the keydown isn't triggered. – pedalpete Jan 10 '14 at 08:22
0

Here is a library you can use to add ctrl+f "find" support in NW.js.

ctrl+a to "select all" is already built in to Normal and SDK versions of NW.js

However, if you want to override the default "ctrl+a", then Andrew's answer is correct and will do that. Listen for the event and prevent default.

Jaredcheeda
  • 1,657
  • 17
  • 15