Pass the original events or add events types in selectionchange

Open
#65 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
html
Domain
api, web-dev

Research direction

Start with the selectionchange callback described in the issue and use the linked JSFiddle to understand the requested behavior. Compare the two proposed approaches—passing the original keyboard or mouse event, or adding event type information—and determine which event shape and triggering cases should be specified. Done means the API behavior and callback event semantics are clearly defined.

Written by the indexing model from the issue text.

Description

NewAPI

selectionchange is really useful, it would be even better if the event parameter of the callback could say more about what triggered the selection change, either passing a MouseEvent, a KeyEvent etc.. or giving a type property to the event

document.addEventListener('selectionchange', e=>{
  if (e instanceof KeyEvent) console.log(e.keyCode) // very useful if I want to act on undo/redo..
  else if (e instanceof MouseEvent) console.log(e.target)// e.target is not really needed
             // since I can use the current Range to know in what elements the selection is
  // ...
});

the idea is to have something like that http://jsfiddle.net/crl/rk6f74tw/12/

Dominant language
HTML
Stars
49
Forks
30
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from w3c/selection-api

All issues in w3c/selection-api

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.