Combining multiple key modifiers such as ctrl.shift+q
nickjj opened this issue · 5 comments
Hi,
The docs cover how to add something like keydown.ctrl+a
or keydown.shift+a
but there's no reference on how to combine multiple modifiers such as keydown.ctrl.shift+a
. I also tried keydown.ctrl+shift+a
. At a quick glance I didn't see any tests for this as well.
Is this feature not available? Are there any plans to support multiple modifiers?
I think this is currently not supported. But maybe @NakajimaTakuya might have an idea how it could look like if we would support multiple modifiers.
Sorry I didn't mention it in the documentation. But that syntax is supported. (keydown.ctrl+shift+a)
It is working on my end, but not working?
https://codepen.io/Takuya-Nakajima/pen/wvQMZGz?editors=1010
And the test exists here.
https://github.com/hotwired/stimulus/blob/main/src/tests/modules/core/action_keyboard_filter_tests.ts#L180-L185
@NakajimaTakuya Thanks. When I looked at the tests I was only looking for an end-to-end syntax example in my search.
If I change your codepen to data-action="keydown.ctrl+shift+8->notifier#notify"
then it doesn't trigger.
That was what I was running locally. Funny enough I also had a 2nd one of keydown.ctrl+shift+.
which didn't work but now I see this one with the .
probably won't work by default due to that key not being in the list of filters. But in theory 8 should match [0-9]? Does it not because shift really changes that to *
which is also not included in the default filter list?
I thought there was some discrepancy, but it seems to be a problem created by the difference between JIS and US keyboards.
On a JIS keyboard Mac, ctrl+shift+8 event.key is 8, event.shiftKey is true, event.ctrlKey is true.
On a US keyboard Windows, ctrl+shift+8 event.key was *, event.shiftKey was true, event.ctrlKey was true.
Does it not because shift really changes that to * which is also not included in the default filter list?
Now maybe @nickjj is using a US keyboardWindows, so 8 is interpreted as *.
So it's probably that * is not in the support list and therefore not being handled.
I'll give it some thought.
Ah nice catch on thinking about different keyboard layouts. I'm using a standard layout US English keyboard on Windows.