James Edwards on Nostr: Writing #javascript to handle #caret browsing is interesting. Since `keydown` only ...
Writing #javascript to handle #caret browsing is interesting.
Since `keydown` only fires for targets that can be `activeElement`, the event target from caret navigating plain text is always <body>.
However you can identify which element contains the caret, by evaluating the range data, which you can also do from `selectionchange` events.
And get this -- Safari still fires those events, even though it doesn't support caret browsing ... because it actually does, it just doesn't show the caret!
Since `keydown` only fires for targets that can be `activeElement`, the event target from caret navigating plain text is always <body>.
However you can identify which element contains the caret, by evaluating the range data, which you can also do from `selectionchange` events.
And get this -- Safari still fires those events, even though it doesn't support caret browsing ... because it actually does, it just doesn't show the caret!