feat(web): implement doModifierPress ✨ 🎼#15343
Conversation
User Test ResultsTest specification and instructions User tests are not required |
doModifierPressdoModifierPress 🎼
1bd3aa5 to
283f43f
Compare
5b3ea22 to
878b8ab
Compare
Fixes: #15287 Test-bot: skip
283f43f to
68de61a
Compare
doModifierPress 🎼doModifierPress ✨ 🎼
mcdurdin
left a comment
There was a problem hiding this comment.
I am not sure about some of the modifier-related changes here, we should discuss
| if (this.activeKeyboard.isMnemonic && this.stateKeys['K_CAPS'] && (!e || !e.isModifier)) { | ||
| // Modifier keypresses don't trigger mnemonic manipulation of modifier state. | ||
| // Only an output key does; active use of Caps will also flip the SHIFT flag. | ||
| // Mnemonic keystrokes manipulate the SHIFT property based on CAPS state. | ||
| // We need to unflip them when tracking the OSK layer. | ||
| keyShiftState ^= ModifierKeyConstants.K_SHIFTFLAG; | ||
| } |
There was a problem hiding this comment.
Is this straight from jsKeyboardProcessor? I just don't quite understand the rationale - shift and caps have different effects on keys (e.g. 1 --> ! / 1 vs a --> A / A for shift and caps respectively)
There was a problem hiding this comment.
Yes, that's from jsKeyboardProcessor:
There was a problem hiding this comment.
Worth reading through the PR and comments that originally added this: #5456
There was a problem hiding this comment.
It looks like that code might not be correct - see #15439.
| case Codes.keyCodes.K_RCTRL: | ||
| case Codes.keyCodes.K_LALT: | ||
| case Codes.keyCodes.K_RALT: | ||
| case Codes.keyCodes.K_ALTGR: |
There was a problem hiding this comment.
This is not a real AltGr. It's a pseudo AltGr that probably should never be used. See its keyCodes value of 50010. May need some further investigation!
| case Codes.keyCodes.K_ALTGR: |
There was a problem hiding this comment.
Does this apply to all keycodes > 50000? If so, what are those? And we should probably add a comment to https://github.com/keymanapp/keyman/blob/feat/web/15287_doModifierPress/common/web/types/src/consts/virtual-key-constants.ts#L130
There was a problem hiding this comment.
Yes, all the keycodes > 50000 are special key codes used only in touch layouts; called TKeymanWebTouchStandardKey in keymanweb-key-codes.ts (in the kmw compiler, translated from Delphi, hence the initial T):
keyman/developer/src/kmc-kmn/src/kmw-compiler/keymanweb-key-codes.ts
Lines 808 to 822 in 90f5ab6
These are predefined to have specific behaviours on a touch layout but no effect on a standard layout. The documentation could be improved; see:
keyman/developer/docs/help/reference/file-types/keyman-touch-layout.md
Lines 106 to 141 in 929b7d7
There was a problem hiding this comment.
I added a comment to virtual-key-constants.ts
| case Codes.keyCodes.K_LSHIFT: | ||
| case Codes.keyCodes.K_RSHIFT: | ||
| case Codes.keyCodes.K_LCTRL: | ||
| case Codes.keyCodes.K_RCTRL: | ||
| case Codes.keyCodes.K_LALT: | ||
| case Codes.keyCodes.K_RALT: |
There was a problem hiding this comment.
These do not currently return true, so this is a functional change which would need extensive testing. I suggest we do not add them here unless we actually have a need for them, or else we audit all uses to ensure that adding these does not break anything.
| { code: Codes.keyCodes.K_NUMLOCK, name: 'NumLock' }, | ||
| { code: Codes.keyCodes.K_SCROLL, name: 'ScrollLock' }, | ||
| // TODO-web-core: should LSHIFT/RSHIFT etc also be detected as modifier? | ||
| // Currently .js keyboards don't don't support distinguishing |
There was a problem hiding this comment.
.js keyboards do support L/R alt and ctrl, but not L/R shift. We don't support L/R shift anywhere in Keyman.
Build-bot: skip Test-bot: skip
…feat/web/15287_doModifierPress
| const lockNames = ['CAPS', 'NUM_LOCK', 'SCROLL_LOCK'] as const; | ||
| const lockKeys = ['K_CAPS', 'K_NUMLOCK', 'K_SCROLL'] as const; | ||
| const lockModifiers = [ModifierKeyConstants.CAPITALFLAG, ModifierKeyConstants.NUMLOCKFLAG, ModifierKeyConstants.SCROLLFLAG] as const; |
There was a problem hiding this comment.
These, together with LL417-419, should be grouped together at the top of the module rather than declared at the top of the function
Fixes: #15287
Test-bot: skip