OscarGodson / jKey

Key shortcuts made simple
http://oscargodson.github.com/jKey/
185 stars 40 forks source link

Fix: Detect missed keyup of Shift/Ctrl/Alt #23

Closed Granjow closed 7 years ago

Granjow commented 11 years ago

Here you go. The indentation is a bit unreadable this way :D

OscarGodson commented 11 years ago

I quickly tested this and I'm not yet sure what this fixes. I know the alert is a problem due to the fact that when you use an alert the browser loses focus on the page before you let go of the keys, but this doesn't seem to fix it, at least with this simple test:

$(window).jkey('alt+d', function () {
  alert('test')
})

If I press alt+d I get an alert. If I then just press alt I get the alert still.

Granjow commented 11 years ago

Yes, this cannot be handled I guess. A workaround for this could be a timeout, assuming that shortcuts are pressed within 2 seconds or so, and releasing keys after that. What the patch handles is that you can, after your test, type «doughnut» in an input field without getting a «test» alert again (for the d).

colszowka commented 11 years ago

:+1:

Granjow commented 7 years ago

Closing because was not merged.