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

WIP: US-International Keyboard Deadkeys #1907

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kwibus
Copy link

@kwibus kwibus commented Oct 17, 2024

This proof of concept for Solution 1 for issues #350

Solution 1, guess dead key from event.code etz.

This has the problem this depends on they keyboard layout. which is unknown to the browser.
But:

You only have to do this for Dead Keys, not all keys
there lots of overlap between keyboard layouts, dead keys list
when the overlap, it works for both
If the conflict you can't resolve it
This is not a perfect solution. But you can get it to work for most used keyboard layouts, with deadkeys.
Which might be better the Nothing.

I have a working POC that works for us international keyboard layout with:

XK_dead_grave: `
XK_dead_diaeresis: "
XK_dead_acute: ´
XK_dead_circumflex: ^
XK_dead_tilde: ~

@kwibus kwibus mentioned this pull request Oct 17, 2024
@kwibus
Copy link
Author

kwibus commented Oct 17, 2024

@sergiomb2 Can you give me some more information:

  • what did you try?
  • which keyboard layout did you use?
  • which OS?

So i can try to reproduce the problem

@sergiomb2
Copy link

sergiomb2 commented Oct 17, 2024

I use PT_pt keyboard layout , in pt layout we have 5 dead keys but I only use 4 (`, ´, ~, and ^) I changed the following code and work perfectly with Firefox browser , with google chrome don't

I use Linux Fedora 39 KDE, novnc 1.4.0

export function getDeadKeysym(evt) {
    switch(evt.code){
        case "BracketRight":
            if (evt.shiftKey){
                return KeyTable.XK_dead_grave
            } else {
                return KeyTable.XK_dead_acute // ´
            }
        case "Backslash":
            if (evt.shiftKey){
                return KeyTable.XK_dead_circumflex
            } else {
                return KeyTable.XK_dead_tilde
            }

@CendioOssman
Copy link
Member

I'm afraid I don't understand the principle here. The code looks to be simply assuming one specific layout as it is just hard-coding what symbol is expected from a specific physical key?

@CendioOssman
Copy link
Member

Using the keyboard layout API might be an option. They seem to have started defining how dead keys should be reported:

https://wicg.github.io/keyboard-map/#dead-and-combining

It's not supported by Firefox yet, though.

@CendioOssman
Copy link
Member

Never mind. It seems Safari has firmly said no to that API because of fingerprinting concerns. And Firefox seem to be of the same opinion:

https://bugzilla.mozilla.org/show_bug.cgi?id=1469017

@kwibus
Copy link
Author

kwibus commented Oct 28, 2024

I'm afraid I don't understand the principle here. The code looks to be simply assuming one specific layout as it is just hard-coding what symbol is expected from a specific physical key?

Yeah that is true, Now it assumes keyboard layout is us-international.
you might be able to expand it a bit. Most keyboard layouts don't have that many dead keys.
But i think its impossible to convert this solution to a generic solution that will work for all keyboard layouts.

@kwibus
Copy link
Author

kwibus commented Oct 28, 2024

I have no longer time to work on this for at least a month.
I hope can make time for this after that

if(key === "Dead" ){
return getDeadKeysym(evt);
}

Copy link

@sergiomb2 sergiomb2 Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to me that key==="Dead" just works in Firefox and not in Chrome .

In firefox I got all accents working perfectly .

But I'd like use one electron app , because I can use ctrl + key , how we catch dead keys in chrome as it here ?

@kwibus
Copy link
Author

kwibus commented Oct 29, 2024

Strange i can not really reproduce that. for me it works on

  • firefox: 131.0
  • google chrome: 130.0

I do see a difference in output between linux, and windows.
and if you check events for text input or not, its different

but for a non text text input, for linux (wayland) . see the same result for google-chrome as firefox.
Do you get a different result, with my test html?

I test it with test.html
test.html.csv

I had to add .csv to be allowed to upload it. so you have to remove the .csv extension.

I test with keyboard layout:

us-international with dead keys.
I type dead key ' (quote)

chrome
firefox

@sergiomb2
Copy link

sergiomb2 commented Nov 16, 2024

yes , thank you, I got all accents working perfectly on chrome 130.0 , from my chromebook .
And it is awesome, all keys are working , accents , ctrl, alt, etc. ctrl + w for example

@CendioOssman CendioOssman marked this pull request as draft November 29, 2024 15:23
@sergiomb2
Copy link

Curiously, with electron 31.7.5 based on Chromium v126.0.6478.234, it doesn't work, or rather there are things that seem to already work but in general it doesn't work, it seems to me that this change requires very updated versions ?

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

Successfully merging this pull request may close these issues.

3 participants