Catch Insert, DeleteKey

4 posts, 0 answers
  1. Cooltisch
    Cooltisch avatar
    10 posts
    Member since:
    Mar 2007

    Posted 12 Feb 2008 Link to this post

    Hi
    I would like to catch in the OnKeyPress Event the Insert and Deletekey. Is that possible? I know some browser does not support this.

    Furthermore the "get_IsCtrlPressed" Property does not work. I get always the message that this method is not supported.
    My Client function:
    function radGridDumOnKeyPress(sender, eventArgs)
    {
      alert("Is Ctrl pressed: " + eventArgs.get_IsCtrlPressed());
    }
    I am using IE7.

    Best regards
    Holger

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 14 Feb 2008 Link to this post

    Hi,

    In order to make sure that the property is properly called, you will need to use slightly different syntax:

    .Js
      function radGridDumOnKeyPress(sender, eventArgs)  
            {  
            alert("Is Ctrl pressed: " + eventArgs.get_isCtrlPressed());  
            } 

    the isCtrlPressed() function starts with lowercase letter.
    Also, unfortunately, you cannot detect the insert/delete key presses. Explorer doesn't fire the keypress event for delete, end, escape, function keys, home, insert, pageUp/Down and tab.
    I hope this information helps.

    Best wishes,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cooltisch
    Cooltisch avatar
    10 posts
    Member since:
    Mar 2007

    Posted 15 Feb 2008 Link to this post

    Thanks for your help. The "Ctrl" issue is solved.
    Is it possible to extend your grid and write an implementation to catch the onkeyup event on client side? This event provide any keycode.

    Best regards
    Holger
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 18 Feb 2008 Link to this post

    Hello,

    Unfortunately, this is a browser behavior. However, you can take an approach similar to the one shown in the code sample below:

    .aspx
    <script type="text/javascript">     
    function OnKeyDown(e)     
    {     
        var isIE = /MSIE/.test(navigator.userAgent);     
        var keyCode = isIE ? e.keyCode : e.which;     
                     
        if(keyCode == 8 || keyCode == 46)     
        {     
             RadControlsNamespace.DomEvent.PreventDefault(e);     
                         
        }                 
    }     
    </script>    
    <rad:RadNumericTextBox onkeydown="OnKeyDown(event)" ID="RadNumericTextBox1" runat="server">     
    </rad:RadNumericTextBox>    
     

    This can be traced in the keydown window handler, for example.
    I hope this information helps.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top