-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add AltGraph as a separate modifier #4237
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
base: master
Are you sure you want to change the base?
Conversation
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.
AltGr is not a modifier, pretending that it's is not expected by anyone.
It also doesn't even work like a modifier, so putting it there is not a good option. If you want to indicate that compose is going on, other options should be used, such as exposing some kind of keymap for the end user, which I plan to do eventually.
Of course it is, both logically - just like Shift prints Upper case of a key AltGr prints Symbol of a key - and "officially", it's recognized as a separate modifier in eg official specs like Web https://w3c.github.io/uievents/#keys-modifiers and defined as such in various other places And this symbolic expectation is also what makes it different from a regular right alt modifier, which the normal expectaton for is to e.g. work with menu shortcuts on Windows (not insert symbols), just like LAlt.
In what way does it not?
It's not compose, it's getting access to 1 for 1 key regardless of previous input (outside of special deadkeys and special unicode composable symbols), just like Shift. Compose is by definition when you ... well, compose a symbol from usually multiple chars. And Compose is a "sticky" state (on older keyboards signalled via an LED light, in some compose apps via a tray icon light or maybe some cursor change UI mechanism like dead keys), which AltGr isn't
|
|
https://w3c.github.io/uievents/tools/key-event-viewer.html I mean, for me it's not a modifier(firefox) on those tools, it's just a
tap -> then you type the sequence to input keys, in some impls it could be done differently by holding, but generally it's a tap dance. |
Maybe that's because how your system is set up? Here is an example with a layout that has AltGr
That's not surprising, in general a lot of this keyboard stuff is pretty broken everywhere. I mean, on Windows you have this dumb design where AltGr is LCtrl+RAlt, so you waste the whole set of Ctrl+Alt key combos That's not a reason not to do it properly.
That's not me, I'm using existing detection. If you believe there are cases when this detection is wrong, ok, but that's a separate bug. Also, even in that case it's not "just right alt" since it will NOT trigger Alt+X shortcuts! That's the important part and the reason to separate these two functionally different modifiers
it's not, in Win docs its Ctrl+Alt
Because then you'll have very common bugs where you can't use Ctrl+Alt key combos just because your AltGr key isn't implemented properly,
This is NOT how AltGr works, you must hold it, same as Shift (ignoring sticky keys), what you're describing is Compose key as I've quoted above. I think you're confusing these two because your system is setup in a way where RAlt is bound to Compose |
I'm just saying that it doesn't look like modifier at all. In this case I guess it'll be fine though.
I meant here the way you detect, and what windows docs say about Also, according to your log in the browser, you have just |
But Windows also automatically inserts LCtrl event, so it's not just
I have Alt (see below), but if you mean I can't have them both, then yeah, I can't, but that's just because the web spec has this very common bug - they don't distinguish betwen left and right modifier state, and since AltGr = Alt+Ctrl, you can't have AltGr + Alt. But also you can't have AltGr + Ctrl on the web But Winit is smarter here - it does distinguish between modifier sides (though not completely)!
(rebased on top of updates in #4235) |
c4e2ec3 to
339b0b2
Compare
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.
I won't comment much on the PR itself, because I really don't know. But having this as a separate modifier sounds reasonable.
c653197 to
da9707c
Compare
Maybe we can use keyboard types at this point for modifiers as well? |
We cannot with the current design on |
da9707c to
a8fc087
Compare
a8fc087 to
3381e4a
Compare
I use I don't know what should happen here. I wouldn't expect to use If anything, it's
This sounds like a separate bug to me: |
Not on Windows, you can map Ctrl+Alt. Though it's advised not to set default keybinds to those due to AltGr conflicts
Why not? What if you don't use all the symbol keys with AltGr, why wouldn't you want to have the option to map them to something more useful? After all, it has the most convenient modifier position - your right thumb finger!
Yes it should, that's how AltGr is defined, it's literally the same as Ctrl+Alt on Windows, there is no extra |
|
@eugenesvk are you referring to this? It sounds to me like applications should not trigger a shortcut for e.g. On Linux, Ctrl+Alt is not equivalent to AltGr. Ctrl+Alt shortcuts are possible while AltGr is also enabled (e.g. in my editor Ctrl+Alt+O is a shortcut while AltGr+O inserts So it sounds to me like AltGr (without other keys) should map to |
|
Yes, the link describes the equivalence on Windows. Though I'm confused by your example, why would Alt+F4 trigger if Ctrl is pressed with these changes?
Ok, but this is a PR for Windows!
And you've now lost the ability to differentiate between a single key press AltGr = RAlt + LCtrl and two key presses LAlt+LCtrl. For what benefit?
This is even worse, why? Why don't you map Shift to empty on all platforms if it's the same as AltGr only with a different set of symbols? |
On Windows... but as you said at the top of this PR, this is still broken.
It's only worse if you care about supporting AltGr+Key shortcuts. Aside from Windows (which it is recommended not to do as noted in the link above), I haven't seen this supported elsewhere. You are right that this is justification for adding AltGr as a modifier, except that you appear to be arguing about hypothetical cases. Personally I just like the clear divide we usually have: shortcuts apply only to F-keys (and media keys ...) or when at least one of Ctrl/Alt/Meta is pressed. Everything else is just text input.
Shift gets used for other things, like Shift+click may be used for mouse selection, so its state must be known.
Usually you don't need to. In fact, I think the only times you'd even care about this stuff is (a) if you're writing a layout editor or (b) if you want a "display label" for a shortcut/action key. For the most part applications don't care about keyboard layouts or shift levels, they just receive mapped text input. |
So? With this PR it can become unbroken
Yes, if you don't care about shortcuts, shortcut improvements will not help. But you forgot to explain why you want to block the improvements. What about the apps that do care about such shorcuts?
It's mostly you mistake uncommon for non-existent, otherwise there are people already using various external keybind remapping apps to overcome various app/platform limitations. For example, I'm using separate keybinding categories of LAlt+X vs LCtrl+LAlt+X vs RAlt+X
And since AltGr is Ctrl+Alt, your clarity is preserved. But also, we don't have this divide: games exist and are very popular. So do more niche cases like modal editors and other Shift,Shift IDEs, so do some web/file browsers and other apps that know that you're not typing text all the time
No, it's not recommended to change the defaults, it has no relevance to user-defined keybinds, if someone doesn't care about Also, it's not recommended because of the conflict, but this PR partially resolves the conflict, so that recommendation is not fully applicable even for defaults.
Ok, but how is this relevant to Windows?
There is also (c) keyboard shortcuts that are not tied to typed symbols, but to physical keys. But also, why ignore layout editors, OSDs and other 'unusual' apps? |
No, AltGr is not Ctrl+Alt. You've made this clear yourself: you want to add
As I said, I have not seen AltGr used in shortcuts before, anywhere. Either as standard shortcuts or even proper support for AltGr shortcuts (aside from it being compatible with Ctrl+Alt shortcuts on Windows).
Aha, so we're talking about differentiating LAlt and RAlt. In that case, why not also LCtrl and RCtrl, and the same for Shift and Meta keys? I believe ArmA3 (game) differentiates left modifiers from right modifiers. Winit does actually support this; you just have to track the modifier state yourself. But should a typical application care about left-vs-right here? In my opinion, no. One more point: are we talking about |
And for your "clear divide" of "one of Ctrl/Alt/Meta is pressed" the sides dont'n matter, so yes, AltGr meats your criterion of a modifier for shortcuts.
So you have actually seen it. People can and do use Ctrl+Alt shortcuts.
That's a different issue, though ultimately they about the same broader issue -differentiating different modifiers. It's just that AltGr is a physical RightAlt key.
What do you mean, "why not" when I do precisely that! This PR is based on #4235 that closes #3611 about side-aware modifiers!
What's more important is that all games differentiate between single keys as text and single keys as shortcuts=commands, that's how you get WASDF to move instead of typing, and that's what breaks your clarity or mandatory Ctrl/Alt/Win keys in shortcuts
Don't think it's entirely accurate, see various issues linked above and #4233 etc. Though I don't know/remember all the issues (think there was also one with focus changes and modifier state changes which require tracking modifier state change and convert it into a physical key state?)
Why does it matter what you think about "usual" and "typical" when winit is not that limited? Are you saying it should not be used in "unusual" apps? And the correct answer - yes, of course apps should care about user comfort! You lose the most ergonomic modifier position without side awareness. And even if the app dev is ergonomically ignorant it should at least not be blocked at the foundational level so that even if all the default keybinds are bad, users should be able to customize to the better ones!
Well, there is no ISO_Level3_Shift on Windows! I can't disambiguate the inherently ambiguous situation when you keep bringing another platform up where it's defined differently. On linux AltGr would reflect L3 Shift, on Windows it reflects physical Right Alt when AltGr is enabled, so Right Alt also sends Left Control |
|
hm, by the way, is it possible to detect whether physical RightAlt acts as AltGr so that you would only treat LCtrl+RAlt as a logical AltGr modifier conditionally, i.e., when the current layout supports it? Does Winit store info about the currently active layout somewhere to query what physical RAlt generates and use that as a conditional check? |
|
You talk about benefits and capability, but gloss over the implication: using separate states makes all shortcut matching default to differentiate between left and right modifier keys. I asked "why not also LCtrl and RCtrl", and here is a reason: common shortcuts like Ctrl+Z would instead have to be mapped to both LCtrl+Z and RCtrl+Z.
Let me re-phrase: are we talking about a semantic third layer ("alternate graphics") or about differentiating Left Alt from Right Alt for use in shortcuts? There aren't many common shortcuts using Alt, but there are a few, e.g. Alt+F4 (close), Alt+Left (back), Alt+Down (page down). Should these function with RAlt? Should a user-defined key-bind like Alt+G function also with RAlt?
Good question; I don't know. And this is why I ask about ISO_Level3_Shift: it can be activated multiple different ways. Normally applications are not supposed to care about this or how key-presses are translated to text-input, though they might care about which modifier keys were used. |
No? You can have APIs that match either sides without losing the capability to differentiate. I do not remove side-agnostic modifiers, only add side-aware ones. But you should direct this API design conversation to the more appropriate place since this PR is about AltGr, not overall side awareness
Nope, they can continue to use the same side-agnostic APIs to set a single Ctrl+Z
Well, both, there are separate PRs that enable separate capabilities, so the answer depends on a specific issue. This PR depends on left vs right, but it's not about LAlt vs RAlt, it's about differentiating LCtrl+RAlt vs RCtrl+RAlt vs LCtrl+LAlt since AltGr is defined as the former.
Nothing in the defaults change depending on this or the other PR! So it would continue to function as is unless the dev/user change it
Again, none of the defaults are forced to change! So however you like. In a text config you usually have separate Alt/LAlt/RAlt. In a GUI config you can have a checkmark that differentiates sides but otherwise Alt is bound as both L/R
It's the opposite, the question is about cases when there are 0 ways to activate AltGr because the layout doesn't support it (again, not Level3Shift, it doesn't exist on Windows, stop purposefully confusing the conversation).
So nothing will change? Who will force apps to care whether AltGr is set incorrectly (from Lctrl+RAlt even on layouts that don't support AltGr)??? They'll just continue to ignore it. Some users might suffer, but not more than today. But also, for the 3rd time: so what do you suggest apps that do care about which modifiers keys were used do? |
Naively, applications will match shortcut modifiers using the whole of (Though it will only work correctly if applications use key_without_modifiers, not
For the second time: track key events and use the |
So what do you expect to happen when you add caps/numlock modifier etc. state which winit currently lacks? #1426
For the second time: it doesn't work, winit doesn't properly track it for the app to have the full picture! But also, what's the point of a framework that has modifier state if apps have to do all the work to recreate it manually? |
|
Some reference on how to detect layout altgr capability https://stackoverflow.com/questions/54588823/detect-if-the-keyboard-layout-has-altgr-on-it-under-windows |


To at least allow separate handling of Ctrl+Alt and AltGr. Though AltGr+Ctrl is still broken and can't be differentiated from AltGr since in the current model without raw key tracking Winit can't get enough info from window messages to detect the artificial Ctrl that Windows sends on AltGr
Another benefit is it allows separating AltGr+X and Alt+X and not fire shortcuts with a key meant to insert symbols is pressed.
changelogmodule if knowledge of this change could be valuable to usersBased on top of #4235 as it needs the side-aware state and the example
Partially addresses #3012