Capture KeyPress Event in CuteEditor

Last post 09-11-2009, 5:17 AM by Kenneth. 2 replies.
Sort Posts: Previous Next
  •  09-10-2009, 9:48 PM 55549

    Capture KeyPress Event in CuteEditor

    hi all
     
    May i know how to capture KeyPress in cute editor ?
     
    is it possible to do that ?
     
    thanks
  •  09-10-2009, 11:13 PM 55553 in reply to 55549

    Re: Capture KeyPress Event in CuteEditor

    hi all
     
    my question is how can i capture which key is pressed ?
     
    my example code is like this
     

    function Call_KeyPress()

    {

    var editor1 = document.getElementById('<% = ceTemplate.ClientID %>');

    //Get the editor content

    var editdoc=editor1.GetDocument();

     

    // attach Event

    if(editdoc.attachEvent)

    {

    editdoc.attachEvent('onkeyup',HandleChange);

    }

    else if(editdoc.addEventListener)

    {

    editdoc.addEventListener('onkeyup',HandleChange,true);

    }

     

    }
     

    function HandleChange()

    {

    alert('12345');

    }
     
    it works fine if i only alert('12345') but response me javascript error (Object Required) when alert(window.event.keyCode);
     
    can someone help me solve this problem ?
     
    thanks
  •  09-11-2009, 5:17 AM 55562 in reply to 55553

    Re: Capture KeyPress Event in CuteEditor

    Hi goh6613,
     
    For now, editor does not support capture key  pressed on firefox.
     
    You can use the code below on IE, google chrome and safari(higher version)
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>   
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    5. <html xmlns="http://www.w3.org/1999/xhtml">   
    6. <head runat="server">   
    7.     <title>Untitled Page</title>   
    8. </head>   
    9. <body>   
    10.     <form id="form1" runat="server">   
    11.         <CE:Editor ID="ceTemplate" runat="server">   
    12.         </CE:Editor>   
    13.     </form>   
    14. </body>   
    15. </html>   
    16.   
    17. <script type="text/javascript">   
    18.   
    19. function CuteEditor_OnChange(editor)   
    20. {    
    21.     var editdoc=editor.GetDocument();    
    22.     var editwin = editor.GetWindow();   
    23.     editdoc.onkeyup= function showKey()   
    24.         {   
    25.         
    26.           alert(editwin.event.keyCode);   
    27.     
    28.         }   
    29.  }   
    30.   
    31. </script>  
    Regards,
     
    Ken
View as RSS news feed in XML