Darep/Beatstream

View on GitHub
app/assets/javascripts/lib/jquery_onenter.js

Summary

Maintainability
A
1 hr
Test Coverage
//= require ./key_codes

jQuery.fn.onEnter = function(callback) {
    return this.each(function () {
        $(this).keyup(function (e) {
            var code = (e.keyCode ? e.keyCode : e.which);

            if (code == keyCode.ENTER || code == keyCode.NUMPAD_ENTER) {
                if (callback) {
                    callback.call(this);
                }
            }
        });
    });
};