I have used this:
document.onkeydown = keyboardDown;
document.onkeyup = keyboardUp;
document.oncontextmenu = function(e){
var evt = new Object({keyCode:93});
stopEvent(e);
keyboardUp(evt);
}
function stopEvent(event){
if(event.preventDefault != undefined)
event.preventDefault();
if(event.stopPropagation != undefined)
event.stopPropagation();
}
function keyboardDown(e){
...
}
function keyboardUp(e){
...
}
Then I catch e.keyCode property in those two last functions - if e.keyCode == 93, I know that the user either released the right mouse button or pressed/released the Context Menu key.
Hope it helps.