Slight problem with jQuery and keypresses in a RadWindow

3 posts, 1 answers
  1. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 05 Dec 2012 Link to this post

    I have an extremely simple radwindow, called as follows: 
         var oWnd = window.radopen(url, "title");
         oWnd.show();

    Once in the window I want to be able to close it simply by hitting the Esc key.  

    I have this code, essentially pieced together from various threads.  :
    The code below works, but only if I click within the body of the RadWindow first or, if on load, I set the focus to a control within the body.

     Anything particularly wrong with this?

       $(window).ready(function () {
                // Handler for .ready() called.
                $(window).keydown(function (e) {              
                    // ESCAPE key pressed
                    if (e.keyCode == 27) {                  
                        var oWnd = GetRadWindow();
                        oWnd.close();
                    }
                });
       });

    function closeWindow() {
                var oWnd = GetRadWindow();
                oWnd.close();
            }
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow)
                    oWindow = window.radWindow;
                else if (window.frameElement.radWindow)
                    oWindow = window.frameElement.radWindow;
                return oWindow;
            }
  2. Answer
    Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 05 Dec 2012 Link to this post

    Hey Boris,

    If you have the latest version of the controls you can just use the Shortcuts collection of the RadWindow.

    Here's a demo that shows you how to do it:

    http://demos.telerik.com/aspnet-ajax/window/examples/keyboardsupport/defaultcs.aspx


    Hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 05 Dec 2012 Link to this post

    Thanks.

    Now to try and do something similar with RadGrid template popups...
Back to Top