Delete node by keybord button

5 posts, 0 answers
  1. Niclas Ahlqvist
    Niclas Ahlqvist avatar
    20 posts
    Member since:
    Nov 2008

    Posted 14 Oct 2011 Link to this post

    Do you have an example of deleting a node by keyboard button click?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Oct 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gotcha
    Gotcha avatar
    64 posts
    Member since:
    Sep 2009

    Posted 03 Aug 2012 Link to this post

    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 
  5. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 06 Aug 2012 Link to this post

    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.
  6. Vsoni
    Vsoni avatar
    9 posts
    Member since:
    Oct 2013

    Posted 20 May 2014 in reply to Niclas Ahlqvist Link to this post

    <script type="text/javascript" language="javascript">
    function detectspecialkeys(e) {
                var evtobj = window.event ? event : e;            
                if (evtobj.keyCode == 46) {                                     
                                      Delete();
                            }                 
            }
            
    document.onkeyup = detectspecialkeys

    </script>
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017