jQuery plugin to detect Konami cheat code sequence How can this be written a bit shorter?

jQuery.konami = function(fn, code) {
    // ↑ ↑ ↓ ↓ ← → ← → B A
    code = code || [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];

    var kkeys = '',
        i = 0;

    $(document).keydown(function(e) {
        var char = String.fromCharCode(e.which).toLowerCase();
        if (char === code[i++]) {
            kkeys += char;

            if (kkeys === code) {
                fn();
                kkeys = '';
                i = 0;
            }
        } else if (e.which === code[kkeys++]) {
            if (kkeys === code.length) {
                fn();
                kkeys = '';
                i = 0;
            }
        } else {
            kkeys = '';
            i = 0;
        }
    });
};
This is almost like code golf; this could probably be shortened.  You just need to keep track of i and when it's past the end of the array, you know all the keys were hit in the correct order.

jQuery.konami = function() {
    function KonamiCode(kFn, kCode) {
        var i = 0;

        $(document).keydown(function(e) {
            var char = typeof kCode === 'string' ? String.fromCharCode(e.which).toLowerCase() : e.which;
            i = char === kCode[i] ? i + 1 : 0;
            if (i === kCode.length) {
                kFn();
                i = 0;
            }
        });
    }
    return function(fn, code) {
        // ↑ ↑ ↓ ↓ ← → ← → B A
        kCode = code || [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
        new KonamiCode(fn, kCode);
    };
}();