w3c / input-events

Input Events
https://w3c.github.io/input-events/
Other
23 stars 16 forks source link

interpretation of user intention expression #65

Open johanneswilm opened 7 years ago

johanneswilm commented 7 years ago

In the discussion about the beforeinput event on Android, it seems like there have been different ideas about what expression of user intention really means. Android seems to lack a way for a user to express semantic editing operations such as "delete softline" or "delete from caret until the end of the word", as keyboards only let the user agent know that a key has been pressed, that a string in the dom should be replaced with a different string, or that that X characters in a specific direction from the position of the caret should be deleted.

The question is now: Should the user agent try to interprete the commands it receives to fit with semantic inputTypes?

For example:

<p>H|ey there!</p>

| = caret

If the user agent recieves a command from the keyboard that it should delete two letters to the right of the caret, should the user agent interprete that as meaning that it should "delte from caret to the end of the word"?

I personally would say no, that the command should continue to just be to delete two characters. But one could argue that this should be left for implementers to be decided.

chaals commented 7 years ago

@johanneswilm:

I personally would say no, that the command should continue to just be to delete two characters. But one could argue that this should be left for implementers to be decided.

If the command is "delete the next two characters" then nothing stops the implementor from mapping it to "delete to end of word", if there is a way to express that... (I'm thinking of the difference between "dw" and "2x" in vi :O ). In the example given, they have the same effect.

What is the a use case - maybe a different example? - for forcing a mapping or insisting on no mapping being made?

johanneswilm commented 7 years ago

Well, they mean different things. For example, the browser may have a different idea about what constitutes a word than the JavaScript. So the browser may think they are the same thing when in reality they are not. The JS devs will be closer to the truth on thsi matter because the site that holds the document with the document is being edited has control over what JS to run, but not how the browser implementation operates.