[CLOSED] KeyMap and browsers events

  1. #1

    [CLOSED] KeyMap and browsers events

    Hi,

    I'm using Ctrl+W and Ctrl+T shortcuts, but it's always the browser event which is fired.

    The following code close the tab and doesn't display my alert.
    @(
        X.Viewport().ID("Viewport").Layout(LayoutType.Border)
        .KeyMap
        (
            X.KeyMap()
            .Target("={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}")
            .Binding(b => {
                b.Add(Html.X().KeyBinding().Ctrl(true).KeysString(((int)KeyCode.W).ToString()).DefaultEventAction(EventAction.PreventDefault).Handler("alert('click');"));
            })
        )
    )
    But the following is working, the only change is the keycode 'A'

    @(
        X.Viewport().ID("Viewport").Layout(LayoutType.Border)
        .KeyMap
        (
            X.KeyMap()
            .Target("={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}")
            .Binding(b => {
                b.Add(Html.X().KeyBinding().Ctrl(true).KeysString(((int)KeyCode.A).ToString()).DefaultEventAction(EventAction.PreventDefault).Handler("alert('click');"));
            })
        )
    )
    How can I use Ctrl+W or Ctrl+T without firing my browser event (close/open tabs)

    Thanks a lot !
    Last edited by Daniil; Jul 10, 2013 at 4:25 AM. Reason: [CLOSED]
  2. #2
    Hi @jdacosta,

    There is always a problem with overriding a browser's hot keys, especially, with serious ones like Ctrl+W, due to browser reason. First, not all browsers allows to do that. Second, if find a solution for some browser, it might not work in another browser. Besides, it can be not nice for an end-user who is used to use browser hot keys and expected the certain behavior.

    Personally, I would strongly recommend not to do that.
  3. #3
    I also do not reccomend it because you change habitual behaviour of browser (user is accustomed for particular behaviour for particular hot keys but you change it)

Similar Threads

  1. Replies: 2
    Last Post: Apr 11, 2013, 9:31 PM
  2. Replies: 6
    Last Post: Sep 04, 2012, 12:59 PM
  3. [CLOSED] Disable KeyMap Events
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 22, 2012, 6:43 AM
  4. Replies: 15
    Last Post: Feb 03, 2011, 1:27 PM
  5. INSERT KeyMap (all browsers)
    By David Pelaez in forum 1.x Help
    Replies: 1
    Last Post: Jan 25, 2011, 2:36 PM

Posting Permissions