This is a migrated thread and some comments may be shown as answers.

global keyboard shortcut?

2 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
pantarhei
Top achievements
Rank 1
pantarhei asked on 22 Oct 2008, 12:50 PM
sorry for doubleposting here. but i posted it to the wrong forum. so please
delete the posting in the menu forum if possible.

is it possible to define global keyboard shortcuts for telerik controls?

e.g. i'd like to display a context menu centered on my site if the user pressed str + [someKey]. is there a telerik way for registering global shortcuts or do i have do use some other lib?

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 24 Oct 2008, 02:09 PM
Hello pantarhei,

You can use the following:

<script type="text/javascript"
function pageLoad() 
    if (window.addEventListener) 
    { 
        document.addEventListener("keyup", onKeyUpHandler, false); 
    } 
    else if (window.attachEvent) 
    { 
        document.attachEvent("onkeyup", onKeyUpHandler); 
    } 
 
function onKeyUpHandler(e) 
    if (!e) 
        e = window.event; 
         
    var code = e.keyCode; 
 
    //Control + m is pressed 
    if (e.ctrlKey && code == 77) 
    { 
        $find("<%= RadContextMenu1.ClientID %>").showAt(300, 300); 
    }        
</script>  

Note that there are already a lot of predefined key combinations so you have to find a unique combination.

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
pantarhei
Top achievements
Rank 1
answered on 24 Oct 2008, 04:23 PM
Hello Veselin,

thx a lot for your reply. in the meantime i figured out how to get things done.
quite similiar to your approach.

js is still rather new to me, thus i don't see the easiest solutions as fast as i'd like to.
thx for your help.
Tags
General Discussions
Asked by
pantarhei
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
pantarhei
Top achievements
Rank 1
Share this question
or