keymanapp / keyman

Keyman cross platform input methods system running on Android, iOS, Linux, macOS, Windows and mobile and desktop web
https://keyman.com/
Other
372 stars 102 forks source link

feat(web): Caps Layer and double-tap gesture 🕊 #5989

Closed mcdurdin closed 2 years ago

mcdurdin commented 2 years ago

Fixes #3620.

Implements the Caps Lock layer support and the double-tap gesture on the shift key to access it.

The double-tap gesture has been implemented with a view to extension to support other multi-tap gestures in the future. However, for now, it is limited to supporting the Shift key, if and only if the keyboard includes a Caps layer.

The reason for this v15 limitation is that multi-tap on regular keys would involve either rewinding the previous keystroke (the first tap), or forcing keyboard developers to consider 'rota' style rules in their keyboards to support the multi-tap gestures, as we need to make sure that the first tap is accepted and processed for immediate feedback. This needs more design, to avoid unnecessary complexity in the keyboards and/or the rewinding of the keystroke (even though that is conceptually supported in Keyman Engine for Web already). Basically, we don't want to constrain the way that a keyboard author may use the multi-tap gesture by hard-coding the rewind, but neither do we want to make all multi-tap gestures needlessly complex to author.

The shift key (and other modifiers, potentially in future) needs special support for multi-tap as the key that is being tapped changes with the layer change. This is currently managed through recognising K_SHIFT in the key id.

I have tried to follow the PendingGesture pattern for multi-tap, and the gesture itself supports a series of taps, not just a double-tap. The maximum time to complete the tap series is 125msec * number-of-taps, so for a double-tap is 250msec.

The changes to support a Caps Lock layer itself were minimal; just adding the text.KeyboardProcessor.getStateFromLayer function and calling it during KeyEvent construction. The remaining changes relate to the multi-tap gesture.

Minor changes:

Note:

User Testing

SUITE_BASELINE: Test that nothing has changed in existing keyboards

  1. Run through basic usage tests of a variety of keyboards, including sil_euro_latin and khmer_angkor.
  2. Test longpress keys, layer switching, flick-up gesture.
  3. For testing on a physical device: test that rapid touches across multiple keys works correctly, as does multi-touch (where you start tapping the next key before releasing the previous, e.g. rapid two-thumb typing). These are not easy to test in an emulator!

SUITE_CAPS: Test that the new Caps Lock layer controls work correctly

  1. Run through a basic usage test of caps_lock_layer_3620.zip.
  2. Double-tap the shift key. Watch how it switches to a Caps layer (see the 'shiftlock' style of the Shift key).
  3. Test that the Caps layer works correctly. Note that the Shift layer on caps_lock_layer_3620 does not shift back to the base layer automatically; this is intentional.
  4. With the full_caps_3620_3621.zip keyboard, test that the Caps layer is accessible through double-tap shift, and that the interactions with Caps Lock and Shift are 'intuitive'.
  5. For testing on a physical device: test that rapid touches across multiple keys works correctly, as does multi-touch (where you start tapping the next key before releasing the previous, e.g. rapid two-thumb typing). These are not easy to test in an emulator!
keymanapp-test-bot[bot] commented 2 years ago

User Test Results

Test specification and instructions

🟥 SUITE_BASELINE: Test that nothing has changed in existing keyboards

🟥 SUITE_CAPS: Test that the new Caps Lock layer controls work correctly

Test Artifacts

MakaraSok commented 2 years ago

SUITE_BASELINE: Test that nothing has changed in existing keyboards

mcdurdin commented 2 years ago
  • Make sure no script errors are encountered

To check for script errors when testing KeymanWeb, open the Developer Console (F12 on Chrome/Windows) -- script errors are shown in red and can be located by clicking the image button in the top right of the Developer Console.

mcdurdin commented 2 years ago

This video no longer appears available?

mcdurdin commented 2 years ago
  • [TEST_BASELINE_ANDROID] In-app: longpress keys are not working in simulator, but OK in a physical device.

This may not be related to this change; can we do a screenshare test together on this?

@keymanapp-test-bot retest SUITE_BASELINE TEST_BASELINE_ANDROID

MakaraSok commented 2 years ago

This video no longer appears available?

https://user-images.githubusercontent.com/28331388/146703733-ae7598e8-b306-4ace-871a-f76fd3df7d64.mp4

MakaraSok commented 2 years ago

SUITE_BASELINE: Test that nothing has changed in existing keyboards

  1. Run through basic usage tests of a variety of keyboards, including sil_euro_latin and khmer_angkor.

OK, but longpress doesn't work on emulator. Nothing like this is seen on a physical device.

  1. Test longpress keys, layer switching, flick-up gesture.

OK

  1. For testing on a physical device: test that rapid touches across multiple keys works correctly, as does multi-touch (where you start tapping the next key before releasing the previous, e.g. rapid two-thumb typing). These are not easy to test in an emulator!

The key preview may disable during a speed tapping. See the screenshot recording in the comment right above.

MakaraSok commented 2 years ago

SUITE_CAPS: Test that the new Caps Lock layer controls work correctly

  1. Run through a basic usage test of caps_lock_layer_3620.zip.

One of the basic usage of the keyboard doesn't work as expected. Long press keys are not responsive; the subkeys do not pop up as expected on Android 10 simulator API 29. Note that this doesn't happen on the physical device.

  1. Double-tap the shift key. Watch how it switches to a Caps layer (see the 'shiftlock' style of the Shift key).

Working OK.

  1. Test that the Caps layer works correctly. Note that the Shift layer on caps_lock_layer_3620 does not shift back to the base layer automatically; this is intentional.

Each key is working OK, but those keys with longpresses on the simulator. On the physical device however, this doesn't happen.

  1. With the full_caps_3620_3621.zip keyboard, test that the Caps layer is accessible through double-tap shift, and that the interactions with Caps Lock and Shift are 'intuitive'.

Each key is working OK, but those keys with longpresses. On the physical device however, this doesn't happen.

  1. For testing on a physical device: test that rapid touches across multiple keys works correctly, as does multi-touch (where you start tapping the next key before releasing the previous, e.g. rapid two-thumb typing). These are not easy to test in an emulator!

The test is not quite practical, but it does appear that the preview went off and on amid typing.

https://user-images.githubusercontent.com/28331388/146709335-7343e4c0-dc42-419d-b042-48551177f31a.mp4

MakaraSok commented 2 years ago

SUITE_CAPS: Test that the new Caps Lock layer controls work correctly

  1. Run through a basic usage test of caps_lock_layer_3620.zip.

Nothing weird observed.

  1. Double-tap the shift key. Watch how it switches to a Caps layer (see the 'shiftlock' style of the Shift key).

Working OK, but the weird thing is the double tap seem unnatural to the touch. You don't hear the two taps, just one is heard. :/

  1. Test that the Caps layer works correctly. Note that the Shift layer on caps_lock_layer_3620 does not shift back to the base layer automatically; this is intentional.

Each key is working OK including longpresses.

  1. With the full_caps_3620_3621.zip keyboard, test that the Caps layer is accessible through double-tap shift, and that the interactions with Caps Lock and Shift are 'intuitive'.

Not only that the double tap is unnatural to the touch, it doesn't enable caps layer at all. Double tap the Shift key and start typing SS gives you Ss instead.

  1. For testing on a physical device: test that rapid touches across multiple keys works correctly, as does multi-touch (where you start tapping the next key before releasing the previous, e.g. rapid two-thumb typing). These are not easy to test in an emulator!

No physical device within reach right now.

MakaraSok commented 2 years ago

SUITE_CAPS: Test that the new Caps Lock layer controls work correctly

  1. Run through a basic usage test of caps_lock_layer_3620.zip.

Nothing weird observed.

  1. Double-tap the shift key. Watch how it switches to a Caps layer (see the 'shiftlock' style of the Shift key).

Working OK, but the weird thing is the double tap seem unnatural to the touch. You don't hear the two taps, just one is heard. :/

  1. Test that the Caps layer works correctly. Note that the Shift layer on caps_lock_layer_3620 does not shift back to the base layer automatically; this is intentional.

Each key is working OK including longpresses.

  1. With the full_caps_3620_3621.zip keyboard, test that the Caps layer is accessible through double-tap shift, and that the interactions with Caps Lock and Shift are 'intuitive'.

Not only that the double tap is unnatural to the touch, it doesn't enable caps layer at all. Double tap the Shift key and start typing SS gives you Ss instead.

https://user-images.githubusercontent.com/28331388/146721426-8d558d95-101d-461f-9477-322b12a1e7b0.mov

  1. For testing on a physical device: test that rapid touches across multiple keys works correctly, as does multi-touch (where you start tapping the next key before releasing the previous, e.g. rapid two-thumb typing). These are not easy to test in an emulator!

No physical device within reach right now.

MakaraSok commented 2 years ago

SUITE_CAPS: Test that the new Caps Lock layer controls work correctly

  1. Run through a basic usage test of caps_lock_layer_3620.zip.

Nothing weird observed.

  1. Double-tap the shift key. Watch how it switches to a Caps layer (see the 'shiftlock' style of the Shift key).

Working OK.

  1. Test that the Caps layer works correctly. Note that the Shift layer on caps_lock_layer_3620 does not shift back to the base layer automatically; this is intentional.

Each key is working OK including longpresses.

  1. With the full_caps_3620_3621.zip keyboard, test that the Caps layer is accessible through double-tap shift, and that the interactions with Caps Lock and Shift are 'intuitive'.

OK

  1. For testing on a physical device: test that rapid touches across multiple keys works correctly, as does multi-touch (where you start tapping the next key before releasing the previous, e.g. rapid two-thumb typing). These are not easy to test in an emulator!

No physical device within reach right now.

mcdurdin commented 2 years ago

Failing test feedback:

As I have now captured the three failure cases as separate issues, I will go ahead and merge this PR, with the caveat that these issues must be resolved before release.

keyman-server commented 2 years ago

Changes in this pull request will be available for download in Keyman version 15.0.180-alpha

MayuraVerma commented 2 years ago

How to enable CAPS LOCK with double tap in Keyboard?

MayuraVerma commented 2 years ago

I have tried in iOS 15.0.188-alpha with EUROSIL no sign of caps lock with double tap on shift key.

MayuraVerma commented 2 years ago

I tested full_caps_3620_3621.zip with iOS 15.0.188-alpha

CAPS lock turns off, after a key stroke CAPS lock should stay in that state until turned off if not there is not difference between CAPS lock and shift layer.

mcdurdin commented 2 years ago

@MakaraSok or @bharanidharanj, are you able to replicate the issues that @MayuraVerma has experienced? Can you work with Mayura to build a reproducible test case so we can resolve this before release?

mcdurdin commented 2 years ago

I have tried in iOS 15.0.188-alpha with EUROSIL

The SIL Eurolatin keyboard has not yet been updated to support Caps Lock 😄

MayuraVerma commented 2 years ago

I have tried in iOS 15.0.188-alpha with EUROSIL

The SIL Eurolatin keyboard has not yet been updated to support Caps Lock 😄

Yes, I realized it later. since then I tested full_caps_3620_3621.zip with iOS 15.0.188-alpha

Capslock works. But I am thinking we are leaving it to the keyboard developer to choose the next layer after output in CAPS layer, default should be it should remain in CAPS layer. Once we enter CAPS layer, only why to get out of CAPS layer should be release the CAPS lock. This is how it works in hardware, we should mimic the same in software keyboard also.

MayuraVerma commented 2 years ago

I have tried in iOS 15.0.188-alpha with EUROSIL

The SIL Eurolatin keyboard has not yet been updated to support Caps Lock 😄

My earlier assumption was, web/ios/android picks up the NCAPS state from kmn. looks like we need to rewrite it mobile version.

mcdurdin commented 2 years ago

My earlier assumption was, web/ios/android picks up the NCAPS state from kmn.

Yeah, unfortunately given how the touch and physical keyboards diverge, we could not find a safe way to do this automatically. My preference is always to give the control to the keyboard designer, in any case -- but the trade-off is that we don't get this kind of behaviour "for free".

mcdurdin commented 2 years ago

Once we enter CAPS layer, only why to get out of CAPS layer should be release the CAPS lock.

There are two ways, in our design, that the Caps Lock layer is released on touch:

  1. When the user touches the Caps Lock key again (or another modifier key accessible on the Caps Lock layer).
  2. When the user switches apps or input contexts. This matches the behaviour of the system keyboards -- Caps Lock state is not maintained long-term, unlike on a hardware keyboard.

So if you are seeing behaviour that does not match those conditions, that is definitely a bug. And if you can give repro steps, that will help us squash the bug!