Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!

Hello all,

I have an app that needs to catch ctrl-P, page-up, page-down, and various other keys.  Of course, most browsers pop up a print dialog when you hit ctrl-P, and other things when you hit the other keys.  I tried adding some javascript code like this to my Default.html

       document.onkeydown = function(e)
            e = e || window.event;
            var c = e.which || e.keyCode;
            c = String.fromCharCode(c).toLowerCase();
            if (
                // ctrl-p/P
                (e.ctrlKey && (c == 80 || c == 112)) ||
                // f-keys
                (c >= 112 && c <= 123) ||
                // insert
                (c == 45) ||
                // up, down, left, right
                (c >= 37 && c <=40) ||
                // page up/down
                (c == 33 || c == 34) ||
                // escape
                (c == 27) ||
                // enter
                (c == 10 || c == 12)
                return false;

Which originally worked, but no longer works.  Either a recent Mozilla or WiseJ update broke it, or maybe there’s a bug that I can’t see.

Has anyone else tried doing this?

Am I even on the right track, or is there a different, recommended way to do this?




David Muse


  • You must to post comments

Ok, I got it to work, more or less.  It looks like I have a problem with focus now, but I should be able to resolve that.


  • You must to post comments

I just tried with this.Accelerators = new Keys[] { Keys.Control | Keys.P }; and I can catch Ctrl-P. Wisej will automatically block the browser from processing the accelerator.

The issue maybe that  you are registering the accelerator on a Form and then pressing Ctrl-P when the form is not active or doesn’t contain the focus. Wisej will process the accelerator only if the keydown is generated by a child widget, otherwise a form would handle accelerators meant for another form.

If you place a main page you can handle accelerators when the user clicks on a blank area. Or use a desktop and register the accelerators there. If the same accelerator is registered in a form and on the parent desktop (or page) and the user presses Ctrl-P while on the form, the accelerator will only be processed by the form that contains the focus.

To debug in the browser, use F12 and place a break in wisej.js __onAccelerator: function (e) {…




  • You must to post comments

Yes.  Accelerators generally work.  I can catch a P, for example, but not a ctrl-P.  I assume this is because the browser is catching it before WiseJ.  Am I correct in assuming that?  And, if so, am I on the right track to prevent the browser from catching it?

  • You must to post comments

Did you try the Accelerators property on the main page or on form?

  • You must to post comments
Showing 4 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json mixin.theme