sendEvent for key events generates inconsistent DOM key events #11094
Comments
Thanks for the comprehensive tests! I'll need to set aside some time to investigate the issues one by one. |
+1, seems like key modifiers are not working the way they're expected to :/ /poke @vitallium |
@vitallium well I'm not sure. Take that simple exemple, using latest Chrome; in the console, run: window.addEventListener('keypress', function(e) {console.log(e.which);}) Then type
Now the same scenario using PhantomJS: var page = require('webpage').create();
page.onConsoleMessage = function(m){console.log(m)};
page.content = '<script>window.addEventListener("keypress", function(e) {console.log(e.which);})</script>';
page.sendEvent('keypress', 's');
page.sendEvent('keypress', 's', null, null, page.event.modifier.alt); That gives:
Did I miss something? I'm using PhantomJS 1.9.0 on OSX ML. |
I find odd that Chrome reports a different Sincerely,
|
@vitallium the page you indicate describes what Firefox does, or any browser that respects standards should do. IMHO, the issues described here come from the QT layer or the phantomJS implementation, not from webkit itself. (I mean, it seems Webkit receives bad key informations, so it generates bad DOM events) |
@JamesMGreene I confirm But, if I'm trying something different that produces no character like window.addEventListener("keypress", function(e) {console.log(e.which, e.ctrlKey);}) Chrome, typing
(don't ask me why Using PhantomJS 1.9 with this script: var page = require('webpage').create();
page.onConsoleMessage = function(m){console.log(m)};
page.content = '<script>window.addEventListener("keypress", function(e) {console.log(e.which, e.ctrlKey);})</script>';
page.sendEvent('keypress', 'k');
page.sendEvent('keypress', 'k', null, null, page.event.modifier.ctrl); I get:
Edit: fixed sample code, so it looks it's working as expected, but differently than in Chrome. |
Perhaps PhantomJS isn't locale aware...? |
Any progress on this? I'm also experiencing this issue. Using PhantomJS 1.9, var page = require('webpage').create();
page.onConsoleMessage = function(m){console.log(m)};
page.content = '<script>window.addEventListener("keypress", function(e) {console.log(e.which, e.altKey);})</script>';
page.sendEvent('keypress', 'r');
page.sendEvent('keypress', 'r', null, null, page.event.modifier.alt); I get:
But in Chrome, I get:
This is breaking my ability to test a hotkey command. Any idea where this issue is on the roadmap or anyone know of a handy dandy work around? TIA. |
@heylookltsme does your Alt-R give anything except a plain ASCII r in a regular browser? |
ctrl-k produces in chrome 11 because IBM-PC behavior (CTRL-A = 1 CTRL-B = 2 CTRL-C = 3, etc) |
+1 |
Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution! |
ljouann...@gmail.com commented:
Disclaimer:
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #1094.
🌟 3 people had starred this issue at the time of migration.
The text was updated successfully, but these errors were encountered: