I am using Silverlight 4.0,in which i am trying to develop a web application.In this application i am implementing keyboard shortcuts like Ctrl+c,Ctrl+U etc..In browsers while using Ctrl+U, debugging window is opening.Is there any way to Override these default behaviours?
How to Override the default behaviour of keyboard keys in Silverlight
188 views Asked by VVN At
2
There are 2 answers
0
On
You can achieve this by adding an eventListner to the document.
document.addEventListener('keydown', keydownevent);
function keydownevent (event){
if(event.ctrlKey && event.keyCode == 85){
event.preventDefault();
alert("You have pressed ctrl+u")
}
}
Now the document will always listen for the keydown event. In order to remove this event you need to remove the eventListner from the document when the socpe of your page ends as
document.removeEventListener('keydown', keydownevent);
You can use
javascriptif you wish to prevent the default actions assigned.