Miserlou / Glance-Bookmarklet

A Speed Reading Bookmarklet
https://gun.io/blog/openspritz-a-free-speed-reading-bookmarklet
MIT License
1.56k stars 247 forks source link

Escape key closes the panel #83

Open jbmartinez opened 10 years ago

jbmartinez commented 10 years ago

Pressing Escape key closes the panel (#81). It should work in all modern browsers.

elicwhite commented 10 years ago

Should this be using keypress instead of keydown?

jbmartinez commented 10 years ago

keypress is the traditional method, but I prefer keydown because:

  1. keypress is deprecated in favor of input event and we should stop using it.
  2. There are many browsers out there which don't support input event.
  3. We're capturing Escape key, which is a non-printing key so it shouldn't trigger a keypress event, although it indeed triggers a keypress on most popular browsers.
  4. This function might be used for other key bindings. What about arrow keys for changing speed?

I should have used thekey property instead of keyCode or which, but it would not work on some browsers.

In any case, replacing "keydown" for "keypress" should suffice for implementing the latter.