Here I'm trying to override the default shortcuts of IE browser. I'm using IE8 for my application.
Let me give an example. I want to override a shortcut ALT+P. The default function of ALT+P in IE is "Open the Page menu". I tried doing the following way, but I'm not able to override it:
<script type="text/javascript">
document.onkeydown = printKeycode;
var isAlt = false;
function printKeycode(e)
{
//alert('11')
var keycodeentered = window.event.keyCode;
if(keycodeentered == 18)
{
isAlt=true;
}
if(keycodeentered == 80 && isAlt == true) // P keycode is 80
{
alert('Combination entered');
window.event.returnValue = false;
}
}
</script>
But I'm not able to override the default functionality. My action is being triggered at the same time the default action is happening. Small observation is, I am able to prevent the default action of shortcuts using CTRL combination. Any clue?
Have a look at this here: Overriding Browser's Keyboard Shortcuts or Disable Internet Explorer shortcut keys or How can I disable Alt-Enter in IE?