Typically, I don't respond to posts that ask for Do-It-All solutions, but I wrote it out and didn't want it to go to waste. Here is a little something to get you started.
// Valid combination of keys
var valid_combo = ['left', 'right', 'bottom', 'top'];
// Stack that stores the last 4 key inputs, including non-arrow keys
var history = [];
// Maps arrow key direction strings to char code
var keys = [];
keys[37] = 'left';
keys[38] = 'top';
keys[39] = 'right';
keys[40] = 'bottom';
$(window).keyup(function(e) {
var key = e.which;
if (key >= 37 && key <= 40)
{
history.push(keys[key]);
}
else
{
history.push("derp");
}
if (history.length > 4) history.shift();
// Array equality using Option 1 - http://stackoverflow.com/a/10316616/773702
if (JSON.stringify(valid_combo) == JSON.stringify(history))
{
console.log("Valid key combination");
}
});
See it in action on jsFiddle