I need to write a function that responds to a click any where on the page by displaying alert() the event name if the user held Shift during the mouse click, or the name of the element that triggered the event if the user held ctrl during the mouse click. I tried to do this, but an alert--the wrong alert pops up whenever someone clicks without holding a key down. This is my script so far:
<!--
<SCRIPT LANGUAGE="Javascript">
function documentClick()
{
if ((documentClick.shiftkey))
alert( "You clicked the Shiftkey when you clicked the document with your mouse." );
}
{
if ((documentClick.ctrlKey))
alert( "You clicked the ctrl key when you clicked the document with your mouse."
}
document.onclick=documentClick;
</script>
-->
If you know what I am doing wrong please help me fix it. Thanks in advance for your help!
Linda
<!--
<SCRIPT LANGUAGE="Javascript">
function documentClick()
{
if ((documentClick.shiftkey))
alert( "You clicked the Shiftkey when you clicked the document with your mouse." );
}
{
if ((documentClick.ctrlKey))
alert( "You clicked the ctrl key when you clicked the document with your mouse."
}
document.onclick=documentClick;
</script>
-->
If you know what I am doing wrong please help me fix it. Thanks in advance for your help!
Linda