According to the DRY-principle, any ideas how to write [this](http://jsfiddle.net/ARTsinn/dxPdw/) 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;
            }
        });
    };

**Update**

Thanks to [NickLarsen](http://stackoverflow.com/users/178082/nicklarsen) for his help. Here's the [final code](https://gist.github.com/4176523).