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

Chrome problems #4

Open
vramdal opened this issue Jul 10, 2013 · 3 comments
Open

Chrome problems #4

vramdal opened this issue Jul 10, 2013 · 3 comments

Comments

@vramdal
Copy link

vramdal commented Jul 10, 2013

Hi, this doesn't seem to work in Chrome (version 27.0.1453.116, Windows 7).

When entering the demo code into the Javascript console:

document.addEventListener("keydown", function(e){ console.log(e.type, e.key, e.char, e.shiftKey) })
document.dispatchEvent(new KeyboardEvent("keydown", { key: "1", char: "!", shiftKey: true }))

... the console starts outputting

keydown undefined undefined false

... as if the key and char properties are not populated.

Is this perhaps related to https://bugs.webkit.org/show_bug.cgi?id=16735 ?

@termi
Copy link
Owner

termi commented Jul 13, 2013

Hi.
Do you try this demo is it working for you?

Can you do KeyboardEvent + "" in console and take a look is it not equal function KeyboardEvent() { [native code] }. If it does, it may indicate that the polyfill did not work. In this case, please run

(function( global ) {
    try {
        return (new global["KeyboardEvent"]( "keyup", {"key": "a"} ))["key"] == "a";
    }
    catch ( __e__ ) {
        return false;
    }
})( this ) 

in console and comment here the answer. If it true and KeyboardEvent + "" === function KeyboardEvent() { [native code] } the problem in my code. If it not the problem is somewhere else.

By the way, your case is working in my chrome currectly: http://clip.corp.mail.ru/clip/m198/1373747235-clip-50kb-xFUheGw5hJBc.png

@vramdal
Copy link
Author

vramdal commented Jul 14, 2013

Yes, that demo works, as in: The keydown and keyup columns reflect the key I'm pressing, but nothing happens in the keypress column (should it?). On that page, I can also paste

document.addEventListener("keydown", function(e){ console.log(e.type, e.key, e.char, e.shiftKey) })
document.dispatchEvent(new KeyboardEvent("keydown", { key: "1", char: "!", shiftKey: true }))

and it outputs

keydown j j false
keydown f f false

etc.

When entering KeyboardEvent + "" I get the constructor code:

"function _KeyboardEvent( type, dict ) {// KeyboardEvent  constructor

etc.

So, everything seems to be working on that page. I'll have to check my code more thoroughly. Sorry about the noise.

@termi
Copy link
Owner

termi commented Jul 15, 2013

keypress is deprecated so I decide not to polyfill it.

Sorry about the noise.

That's all right!

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

2 participants