This is a migrated thread and some comments may be shown as answers.
Delete node by keybord button
4 Answers 28 Views
This is a migrated thread and some comments may be shown as answers.
Niclas Ahlqvist
Top achievements
Rank 1
Niclas Ahlqvist asked on 14 Oct 2011, 07:41 AM
Do you have an example of deleting a node by keyboard button click?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 14 Oct 2011, 08:45 AM
Hello Niclas,

You can achieve this by attaching OnClientKeyPressing  event. Here is a sample code which deletes the node on Delete key press.
javascript:
function OnClientKeyPressing(Sender, args)
{
     if (args.get_domEvent().keyCode() == 127)//Checking for delete key
       {
           var node = args.get_node()
           Sender.trackChanges();
           node.get_parent().get_nodes().remove(node);
           Sender.commitChanges();
       }
 }

Thanks,
Shinu.
0
Gotcha
Top achievements
Rank 1
answered on 03 Aug 2012, 11:59 PM
Hi,

Is the Delete Key 127 or 46 ?
I did some googling... and im getting 46... 
http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes 
http://www.javascripter.net/faq/keycodes.htm 
0
Helen
Telerik team
answered on 06 Aug 2012, 04:19 PM
Hi Cyril,

Actually they both should work for the "Delete" key:
http://forums.asp.net/p/1514918/3621240.aspx

Kind regards,
Helen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Vsoni
Top achievements
Rank 1
answered on 20 May 2014, 05:51 AM
<script type="text/javascript" language="javascript">
function detectspecialkeys(e) {
            var evtobj = window.event ? event : e;            
            if (evtobj.keyCode == 46) {                                     
                                  Delete();
                        }                 
        }
        
document.onkeyup = detectspecialkeys

</script>
Asked by
Niclas Ahlqvist
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Gotcha
Top achievements
Rank 1
Helen
Telerik team
Vsoni
Top achievements
Rank 1
Share this question
or