Why Nostr? What is Njump?
2024-05-16 18:40:00

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!
Author Public Key
npub1t4u2jqzxdjr66fmdkvfgggs08tpkz8uagr2wp7dd4058vuantc9qdu07pz