Sometimes we want call a function if user pressed two keys together at the same time. Like Shift+Enter, CTRL+S more others, I wrote a little code how to call a function if user pressed two keys. copy keys name from another post Keycodes in javascript to use easily with key names.
[javascript]
var j = jQuery;
shift = 16;
enter = 13;
var shift_pressed = null;
j(document).ready(function (){
var shift_enter=null;
j(‘body’).delegate(‘.shiftenter’,’keydown’,function (eve){
if(eve.keyCode==shift){
shift_pressed=true;
}
})
j(‘body’).delegate(‘.shiftenter’,’keyup’,function (eve){
var this_ele = j(this);
if(eve.keyCode==shift){
shift_pressed=false;
}
if(eve.keyCode==enter &&shift_pressed==true ){
//here is shift+enter pressed
//CALL YOUR CODE……
}
})
})
[/javascript]