dmauro / Keypress

A keyboard input capturing utility in which any key can be a modifier key.
http://dmauro.github.io/Keypress/
Apache License 2.0
3.18k stars 313 forks source link

Example text typo #28

Closed lexey111 closed 10 years ago

lexey111 commented 10 years ago

Please, replace "var listener = window.keypress.Listener();" to "var listener = new window.keypress.Listener();" on your site.

I had an interesting five minutes to understand why it does not work when I copied it from your example :)

dmauro commented 10 years ago

Thanks for catching that. Sorry for wasting your time!

Mithgol commented 10 years ago

@dmauro

Consider using John Resig's self-calling constructor pattern, e.g. adding the following to the beginning of your constructor:

if (!(this instanceof Listener)) return new Listener(element, defaults);

This will allow omitting new, like no one writes new $ for John Resig's jQuery.