Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call event.preventDefault()? #83

Open
nomeata opened this issue Aug 11, 2016 · 0 comments
Open

Call event.preventDefault()? #83

nomeata opened this issue Aug 11, 2016 · 0 comments

Comments

@nomeata
Copy link
Contributor

nomeata commented Aug 11, 2016

My browser, when I start typing into something that is not an entry field (such as the canvas here), it opens a search bar, which then takes focus. This is not desirable when interacting with, say, a game.

I expect there to be similar situations in other environments, where a key press, which is meant to be handled by the application, has other unwanted effects.

The solutions is to call e.preventDefault() in Trigger. But this would disable all keyboard interaction, which is probably not what we want either (e.g. Ctrl-R is very useful).

So I propose to leave every Ctrl-Key-Combo to the browser, but consume all other events, using this code in index.html:

            function Trigger(e) {
        /* Do not handle Ctrl key combos*/
        if (e.which != 17 && !e.ctrlKey) {
                    var o = {};
                    o.metaKey = e.metaKey;
                    o.type    = e.type;
                    if (e.pageXY != undefined) {
                        o.pageXY = e.pageXY;
                    }
                    if (e.pageX != undefined && e.pageY != undefined) {
                        o.pageXY = [e.pageX,e.pageY];
                    }
                    if (e.which != undefined) {
                        o.which = e.which;
                    }
                    $.kc.event(o);
            e.preventDefault();
        }
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant