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

Catch Insert, DeleteKey

3 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Holger
Top achievements
Rank 1
Holger asked on 12 Feb 2008, 07:00 AM
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

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 14 Feb 2008, 02:13 PM
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
0
Holger
Top achievements
Rank 1
answered on 15 Feb 2008, 07:37 AM
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
0
Yavor
Telerik team
answered on 18 Feb 2008, 02:31 PM
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
Tags
Grid
Asked by
Holger
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Holger
Top achievements
Rank 1
Share this question
or