Event.observe(window, 'load', init, false);
var shiftPressed = 0;
function init(){
watchShiftClick($('clickLink'));
Event.observe(document, 'keydown', keyHandlerDown, false);
Event.observe(document, 'keyup', keyHandlerUp, false);
}
function watchShiftClick(link) {
Event.observe(link, 'click', shiftFunction, false);
/*safari 2.0.3 Event.stop(e) workaround*/
link.onclick = function() {return false;};
}
function keyHandlerDown(event){
if(event.shiftKey) window.shiftPressed = 1;
}
function keyHandlerUp(event)
{
/* there's no event.shiftKey onkeyup response
so this detects it */
var key = event.which || event.keyCode;
if (key == 16) {
window.shiftPressed = 0;
}
}
function shiftFunction(e) {
Event.stop(e);
if (shiftPressed == 1) {
/*shiftClick function*/
console.log('shift-click');
} else {
/* click function*/
console.log('click');
}
}