keymanapp / keyman

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

spec(web,developer): multitap and flick for touch keyboards 🐵 #5029

Closed mcdurdin closed 9 months ago

mcdurdin commented 3 years ago

This is part of a broader specification for Caps Lock support on touch devices. Development of this touches multiple components; each component will be implemented in a separate PR, referencing this issue.

This feature has emerged from the caps layer feature and is now treated separately for implementation.

Related features

Introduction

A caps layer, if present, will be accessible by double-tapping the Shift key. We won't add a longpress to Shift because in future we might want to use this for multitouch approach (e.g. hold Shift, press X with another finger to give a capital X and return to default). (Also, double-tap is standard Caps-lock UX)

The double-tap will be defined by a new attribute for keys, called multiTap. This will be an array similar to the subkeys array. Although the key cap won't be initially meaningful, we will store it in case we want to use it for visual feedback in a future version (e.g. a brief popup).

C5029.1 File Formats: .keyman-touch-layout changes

Changes to the file format and the JSON schema are required.

  1. Required: Add a multiTap property to the key object. This will be an array in the same format as the existing sk longpress property.

    We will not require specific key codes for multitap. A recommended pattern would be T_2X_A, T_3X_A for a double tap and a triple tap on an 'A' key.

  2. Optional: Add flick object to the key object. This will be an object with cardinal directions n,e,s,w and intercardinal directions ne,se,sw,nw as properties of the object. Each of those properties will be a key in the same format as the keys in the sk array. (Note: LDML has a flick property so we may need to implement this in order to complete the LDML implementation.)

Backward compatibility

Touch layout files that contain these features will be backwardly compatible with earlier versions of Keyman, with a graceful degradation of functionality.

C5029.2 Changes to Developer IDE

C5029.3 KeymanWeb enhancements

Caps Lock Interaction: double-tapping Shift will switch to the caps layer.

The time between the two taps should be less than 300ms to be treated as a double tap. If the time between taps is longer than that, the second tap should trigger a normal key interaction. Any other interaction after the first tap will cancel the double-tap state.

Subsequent taps in a multi-tap sequence will never trigger a longpress or a flick.

C5029.4: Android and iOS changes

Related Issues and discussions

mcdurdin commented 2 years ago

Most of the KeymanWeb-side infrastructure for multi-tap is implemented in #5989, as a generalized solution with a specialized case for Shift -> Caps in 15.0.

Developer-side infrastructure is needed, plus a more detailed discussion of how to handle multitap and rollback (while we could use the transcriptions feature, it is not entirely clear to me that this is the most appropriate way to solve this):

  • Required: KeymanWeb will need to use the transcriptions feature to roll back previous outputs in the multitap sequence. Layer changes will not be rolled back, just output.
MayuraVerma commented 2 years ago

Is it possible to enable double tap gesture for all keys in version 15? there is no need for developer GUI, we can edit the source in textpad, as long as keyman can compile it. developer gui can wait. double tap will make a huge difference I can finally release the keyboard

mcdurdin commented 2 years ago

Is it possible to enable double tap gesture for all keys in version 15?

Unfortunately not.

there is no need for developer GUI, we can edit the source in textpad, as long as keyman can compile it.

The developer GUI is probably the easiest bit. The file formats are not too bad either. The hard part is the interaction with existing rules in the keyboard. You have to do one action, and then undo it again, before applying the double-tap action -- for example, if you press a, then the keyboard emits "a", but then the double-tap gives "A", you have to delete the "a" and replace it with the "A". That's the easy version. What if the keyboard actually changes the context for the a. Then you have to remember what it had done, undo it, and bring back the original! That also means that the double-tap has to work with the context of the previous keystroke.

So this work can be done in Keyman or in the keyboard. I think that putting that work into the keyboard would make it very difficult to program. Now internally, Keyman has the model for handling these transforms -- it uses this for predictive text -- but there are a lot of details to work through.

For Shift, there was less of a problem, because the Shift key does not emit any characters. That's why we were able to get Shift / Caps into Keyman 15.

But this is still a priority for us -- double-tap, swipe down and potentially other gestures.

MayuraVerma commented 2 years ago

Actually double tap, doesn't need to done in two steps.

Single tap -> a Double tap -> A

In keyboard layout source definition, we need multiple layer, base, shift, NCAPS, doubleTap, pressHold, etc Keyman Engine should take the output from here, predictive text should engage after the text is outputted

Example, predictive text engine doesn't need to know aa is A, we could have keyboard with a in base layer in key_A, below it 1 in shift layer shift_key_A, double tap double_key_A could be programmed directly to output A.

Double tap should not affect the predictive text, until the gesture is complete, text is released.

Please do not implement a, delete, A to proceed to double tap, predictive text will get slow and text will be changing frequently while typing

I have few people test Keyman who uses Android, they all have one major feedback, it's basic keyboard without gestures

Similar feedback for Windows version without predictive text

in keyboard source we need additional layer, engine needs to recognize these layers, gesture definition to pickup input in GUI, output the corresponding text in that layer (double). Predictive text updates with the text output

FYI: Double tap, hold and release in android is most requested

Windows: predictive text

If I help in reducing the workload, please let me how I contribute

I am working on closing iOS, color and icon to match stock keyboard. I will send a pull request soon

mcdurdin commented 2 years ago

Actually double tap, doesn't need to done in two steps.

Single tap -> a Double tap -> A

In keyboard layout source definition, we need multiple layer, base, shift, NCAPS, doubleTap, pressHold, etc Keyman Engine should take the output from here, predictive text should engage after the text is outputted

Example, predictive text engine doesn't need to know aa is A, we could have keyboard with a in base layer in key_A, below it 1 in shift layer shift_key_A, double tap double_key_A could be programmed directly to output A.

Double tap should not affect the predictive text, until the gesture is complete, text is released.

Yes, certainly we can delay on the predictive text; that's not a problem. But we can't really delay on character output into the document.

The issue is the double-tap timing threshold. If the threshold is say, 125msec (any slower is two keystrokes), then this may be workable -- the delay in output becoming visible may not be very noticeable. However, a realistic double-tap threshold is probably significantly higher, say 250msec or even 500msec (and may be user adjustable for accessibility), and if we don't output anything for that long, the keyboard will feel very "laggy". So I don't think this will work.

mcdurdin commented 2 years ago

FYI: Double tap, hold and release in android is most requested

Windows: predictive text

Thank you for the feedback. That helps in our planning.

If I help in reducing the workload, please let me how I contribute

I am working on closing iOS, color and icon to match stock keyboard. I will send a pull request soon

Thank you -- I look forward to seeing it!

mcdurdin commented 2 years ago

Per https://github.com/keymanapp/keyman/pull/6138#issuecomment-1045485483:

With longpress, we are seeing the popup keys. Is it possible for longpress to output shift layer as output instead of popup keys?

It makes sense to make the default longpress selectable by the keyboard developer, as part of the whole gesture feature update for 16.0.

mcdurdin commented 2 years ago

Need to ensure we support #5511 and #1115 - flick gesture on spacebar - and warn devs not to use L/R flick on spacebar in Keyman Developer.

Note: @MayuraVerma requests: "Shortcut to emoji keyboard in Android. It’s simple built in routine to map. Or gesture swipe to space bar to emoji keyboard".

mcdurdin commented 2 years ago

See also #5790 - perhaps implementing with two finger slide on spacebar area?

mcdurdin commented 2 years ago

I'm waiting for the implementation of the swipable keys on mobile.

:grin: This is scheduled for 16.0, due for release later this year -- all going well!

mcdurdin commented 2 years ago

Per https://community.software.sil.org/t/flick-layout-mobile-swipe-from-key-for-different-letter/6036

Requirements:

MayuraVerma commented 2 years ago

Does this include swipe to type feature?

mcdurdin commented 2 years ago

@JapanYoshi is correct -- swipe or touch-trail typing requires good predictive text dictionaries to function well, which most of the languages we support just don't have, so it's not currently high on our priority list.

MayuraVerma commented 1 year ago

can we test multitap gesture in keyboard, if so please point to keyboard syntax.

jahorton commented 1 year ago

can we test multitap gesture in keyboard, if so please point to keyboard syntax.

The new gesture engine (#7324) is not ready at this time, so unfortunately, testing such gestures is not possible yet. It's taking more time than we anticipated and may not release as part of 16.0.

jahorton commented 1 year ago

So, we had a minor design discussion today. One of the important details is that we fleshed out some ideas for flick-hints; I'd like to record that now.

MayuraVerma commented 1 year ago

@mcdurdin is there plan to implement "long press and release" to invoke shift layer

Or "long press and release" to invoke the default key in pop up keys?

jahorton commented 1 year ago

We'll have to see if it lands in this version, but we have plans to do what I've termed a "modifierpress" (or "modipress" for short) - longpress a modifier key to swap to the layer, then swap back when the key is released. I think that corresponds to your first question pretty well.

He and I had a discussion on the second point just last week; see #9416, which was also added to the checklist at the top of this issue.

MayuraVerma commented 1 year ago

If at least the "press and release" gesture can have a default key, which can be simply the first key in the pop up keys, then that is plenty.