-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat: support for different keyboard layouts #24249
Conversation
fd356dd
to
75ef7cf
Compare
This comment has been minimized.
This comment has been minimized.
4cf527f
to
24a5e9e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
147c9d4
to
7c72866
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
dee2c54
to
d208742
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Thank you for your great contribution!
We discussed it in our team meeting and would like to just go with the 5 most common keyboard layouts instead of all of them for the beginning. We can follow up for more (bundle size is our reasoning for now). Also it would be cool if its possible to find another way of getting the data for our generation. Since scraping is not ideal.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@mxschmitt do you already know which keyboard layouts you want to start with, so that I can adjust everything? (tests. documentation, etc.) |
This would be our preferred list:
thanks! |
Arabic is tricky, because it contains ligatures (see #24249 (comment)). The generator extracts them, but as they are not a multi-unicode characters, they are not yet handled properly by current playwright implementation. I did some tests and it doesn't seem to have a trivial solution, so I suggest we open an issue for ligature characters and address arabic keyboard layouts after that. For reference, here are the actual key events sent when pressing |
Great investigation! Actually I added it by mistake, since as you said blocked by #5777. Feel free to leave it out. |
Here is the list, with their codes (I'm using both
|
I'm doing some deadkey tests. There are some discrepancies among browsers: for instance, with Portuguese keyboard layout and Windows 11, key chromium firefox Nevertheless, |
Another doubt: reading I think we could handle them propertly in Let me know your thoughts. |
Logic for dead keys handling added. See microsoft#24249 (comment) See microsoft#24249 (comment)
Logic for dead keys handling added. See microsoft#24249 (comment) See microsoft#24249 (comment)
1c8bbbb
to
5011334
Compare
This comment has been minimized.
This comment has been minimized.
2ca960b
to
480e4ee
Compare
Thanks @dgozman. I just rebased my branch,removed those extra commits trying to fix the unmapped deadkey, and adapted the code not to fail in that scenario. Now, pressing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot to publish review comments!
Test results for "tests 1"6 flaky 26207 passed, 595 skipped Merge workflow run. |
Test results for "tests 1"11 flaky 25722 passed, 595 skipped Merge workflow run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, just a few more comments.
deadkey is considered active when pressed down, and is not reset when some keys are pressed.
Test results for "tests 1"23 passed Merge workflow run. |
Test results for "tests 1"1 failed 6 flaky 25756 passed, 595 skipped ❌ [playwright-test] › reporter-html.spec.ts:1491:7 › merged › labels › filter should update stats
Merge workflow run. |
Test results for "tests 1"1 failed 9 flaky25819 passed, 605 skipped Merge workflow run. |
@dgozman @mxschmitt did you had a chance to review this? I noticed that 1.38 was released already, so at least I'll have to change versions in documentation. |
@ruifigueira This looks good. I was waiting for v1.38 to ship, so this can go to v1.39. Please update |
60d714a
to
c741f9d
Compare
Done, updated to 1.39. |
Test results for "tests 1"1 failed 10 flaky25825 passed, 606 skipped Merge workflow run. |
@dgozman any updates? |
Short summary We've discussed this feature once more, and we'd prefer to postpone it for now, until we gather more feedback on More details Your work has prompted us to make changes to the Given that keyboard layouts feature is a smaller subset of Next steps With the next 1.39 release, I'll ask for more feedback on the usecases for |
@dgozman I noticed that API change and I actually thought what would be the impact in this PR, but I wasn't expecting this, after all the work I had 😔. I understand your explanation, but that still leaves a void on trusted key events for any character not available in US keyboard layout, similar to IME events, but with the difference that playwright internally already has a way to have full keyboard events support. Currently, we can do it low level by creating a CDP session and use the Input.dispatchKeyEvent method, but that only works on chromium. Both webkit and firefox sessions are not available in client API (and even if they were, their protocols appear to be internal), and so there's no chance to fire trusted events there for non-US characters there. I honestly don't have an alternative proposal, but playwright is able to do so many incredible things like intercepting requests and change them on the fly, that it just feels odd that it cannot fire some basic trusted events for non-US keys. |
@ruifigueira Thank you for working on this PR! Unfortunately, we decided to close it for now, since we do not think that implementing this feature is worth the maintenance cost at the moment. Given the update in #7396 and no strong reactions to this call, it seems like there is not enough interest in this. I am sorry that we haven't researched this much earlier, and so you and me spent more time on this PR than necessary. That said, I hope that we learned a few things along the way 😄 Again, thank you for the great work you've done! I am looking forward to more collaboration if you'd like. |
I understand, and I actually noticed that it was more complex than I initially thought (for instance, different events in Windows and MacOS on dead keys). And I did learn a lot on the way playwright works internally, which was great. No hard feelings. That been said, it would be great if there was a way to generate custom key / composition events, even if with a low level API like the chromium CDP session. As I said previously, there are some scenarios where we need to test some trusted key events and there's no way to do that in firefox and webkit. |
I think discussion about composition events should be in #5777. |
Layouts were generated from scraping kbdlayout.info (see
generate_keyboard_layouts.js
).For locale mapping, see #7396 (comment)
There are some things to improve:
PW_KEYBOARD_LAYOUT
but I think it probably should be abrowserContext
optionRefs: #7396