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

Cancel key press

3 Answers 98 Views
Editor
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 01 Feb 2008, 03:18 PM
Hi

In the editor is there a way to cancel key presses? I've tried a couple of things (onkeyup return false etc). But the key pressed still gets into the text?

Thanks
David

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 04 Feb 2008, 01:34 PM
Hi David,

You may try with onkeydown event because it is fired before the character is placed in the editor. I have implemented one sample project on the required functionality, please have a try and in case of some questions do not hesitate to ask.

Sincerely yours,
George
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Manju
Top achievements
Rank 1
answered on 08 Aug 2017, 09:12 PM
I know this is a very old thread. But, how do we do it with latest version. Same code found in the attachment does not work with V2017 editor control. 
0
Rumen
Telerik team
answered on 09 Aug 2017, 08:25 AM
Hi,

You can prevent the key execution with $telerik.cancelRawEvent(e);
You can get the selected element with editor.getSelectedElement() 

Here is an example how to disable the typing inside an A tag:

<telerik:RadEditor ID="r1" runat="server" OnClientLoad="OnClientLoad">
    <Content>
dasdsad <a href="http://abv.bg" >test</a> dasdassd
    </Content>
</telerik:RadEditor>
<script type="text/javascript">
    function OnClientLoad(editor, args) {
        editor.attachEventHandler("onkeydown", function (e) {
                      
            if (editor.getSelectedElement().tagName.toLowerCase() == "a") {
                $telerik.cancelRawEvent(e);
            }
        });
    }
</script>


Regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Editor
Asked by
David
Top achievements
Rank 1
Answers by
George
Telerik team
Manju
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or