Catch Ctrl+Alt+<letter>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Gorodyansky

    Catch Ctrl+Alt+<letter>

    Hi,

    Question about
    event.altKey
    event.ctrlKey
    event.shiftKey


    If I need to catch when a user does say Ctrl+Alt+G -
    somehow event.altKey is not working, i.e.:


    a) I press Shift+K and this works:


    if (evt.shiftKey)
    {
    alert("******** ****** Shift");
    ....
    }

    b) I press Ctrl+K and this works:

    if (evt.ctrlKey)
    {
    alert("******** ***** Ctrl");
    .........
    }

    c) But when I press Ctrl+Alt+K - nothing:

    if (evt.ctrlKey && evt.altKey )
    {
    alert("******** ********** CTRL+Alt");
    ...
    }


    Anyone knows why?


    --
    Regards,
    Paul
  • Janwillem Borleffs

    #2
    Re: Catch Ctrl+Alt+&lt;le tter&gt;

    Paul Gorodyansky wrote:[color=blue]
    > c) But when I press Ctrl+Alt+K - nothing:
    >
    > if (evt.ctrlKey && evt.altKey )
    > {
    > alert("******** ********** CTRL+Alt");
    > ...
    > }
    >
    >
    > Anyone knows why?
    >[/color]

    Be shure to attach it to an onkeydown event.


    JW



    Comment

    • Paul Gorodyansky

      #3
      Re: Catch Ctrl+Alt+&lt;le tter&gt;

      Janwillem Borleffs wrote:[color=blue]
      >
      > Paul Gorodyansky wrote:[color=green]
      > > c) But when I press Ctrl+Alt+K - nothing:
      > >
      > > if (evt.ctrlKey && evt.altKey )
      > > {
      > > alert("******** ********** CTRL+Alt");
      > > ...
      > > }
      > >
      > >
      > > Anyone knows why?
      > >[/color]
      >
      > Be shure to attach it to an onkeydown event.
      >[/color]

      It is attached to onkeypress event. Does it matter?

      I wrote a code based on the example by Martin Honnen -


      So I have
      <textarea ... onkeypress='ret urn changeKey(this, event, fName)'>

      and in that changeKey() function I am trying to use
      Ctrl+Alt+letter thing

      Again, I can catch event.ctrlKey and event.shiftKey but not

      event.altkey
      and not
      (event.ctrlKey && event.altkey)

      --
      Regards,
      Paul

      Comment

      • Janwillem Borleffs

        #4
        Re: Catch Ctrl+Alt+&lt;le tter&gt;

        Paul Gorodyansky wrote:[color=blue]
        > It is attached to onkeypress event. Does it matter?
        >[/color]

        Yes it does, attach it to the onkeydown event as I said before.
        [color=blue]
        > Again, I can catch event.ctrlKey and event.shiftKey but not
        >
        > event.altkey
        >[/color]

        It's not "event.altk ey" but "event.altK ey".


        JW



        Comment

        • Paul Gorodyansky

          #5
          Re: Catch Ctrl+Alt+&lt;le tter&gt;

          Janwillem Borleffs wrote:[color=blue]
          >
          > Paul Gorodyansky wrote:[color=green]
          > > It is attached to onkeypress event. Does it matter?
          > >[/color]
          >
          > Yes it does, attach it to the onkeydown event as I said before.
          >[color=green]
          > > Again, I can catch event.ctrlKey and event.shiftKey but not
          > >
          > > event.altkey
          > >[/color]
          >
          > It's not "event.altk ey" but "event.altK ey".
          >
          > JW[/color]

          Hi,

          I was a typo _here_, not in the code - in the code it's correct

          Thanks,
          Paul

          Comment

          • Paul

            #6
            Re: Catch Ctrl+Alt+&lt;le tter&gt;

            Anyone?


            --
            Regards
            Paul

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: Catch Ctrl+Alt+&lt;le tter&gt;

              Paul wrote:
              [color=blue]
              > Anyone?[/color]

              Yes.


              PointedEars

              Comment

              Working...