fire a keypress event

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

    fire a keypress event

    Hi, all

    Is that possible to fire a "tab" key press event with javascript?

    jack


  • Vincent van Beveren

    #2
    Re: fire a keypress event

    > Is that possible to fire a "tab" key press event with javascript?

    Not that I know of, but what is it you want to accompish with it?
    Maybe it can be done in a different way.



    Comment

    • datactrl

      #3
      Re: fire a keypress event

      I would like to use shift+left as shift+tab and shift+right as tab.

      jack


      Comment

      • Vincent van Beveren

        #4
        Re: fire a keypress event

        > I would like to use shift+left as shift+tab and shift+right as tab.

        There is a object.fireEven t method, and a document.create Event method..
        you could try to manipulate those, but I tried, and I didn't succeed in
        emulating a tab or shift-tab.

        Comment

        • datactrl

          #5
          Re: fire a keypress event

          Thanks Vincent.

          I ve tried to change the key code in keyDown event. It will work for
          shift+left for shift+tab. For shift+right for tab, because shiftKey property
          is readonly, just can't set it to false. So it works as shift+tab as well.
          That's the problem!

          Jack
          "Vincent van Beveren" <vincent@provid ent.remove.this .nl> wrote in message
          news:40c5c514$0 $48959$e4fe514c @news.xs4all.nl ...[color=blue][color=green]
          > > I would like to use shift+left as shift+tab and shift+right as tab.[/color]
          >
          > There is a object.fireEven t method, and a document.create Event method..
          > you could try to manipulate those, but I tried, and I didn't succeed in
          > emulating a tab or shift-tab.
          >[/color]


          Comment

          • Vincent van Beveren

            #6
            Re: fire a keypress event

            In the event, you can fire a new event.

            newevent = document.create EventObject(old event)

            The new event is a copy of the other event, except for that you
            can modify everything.

            newevent.shiftK ey = false;

            Now you'll need to resend it though.

            oldevent.srcEle ment.fireEvent( "on"+oldevent.t ype,newevent);

            Look at the MSDN for more info
            Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

            Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


            Something like that.

            Though I must admit, I didn't get it to work, this should work (in
            theory)

            Good luck,
            Vincent

            datactrl wrote:[color=blue]
            > Thanks Vincent.
            >
            > I ve tried to change the key code in keyDown event. It will work for
            > shift+left for shift+tab. For shift+right for tab, because shiftKey property
            > is readonly, just can't set it to false. So it works as shift+tab as well.
            > That's the problem!
            >[/color]

            Comment

            • datactrl

              #7
              Re: fire a keypress event

              Thanks Vincent, I put the following code on "onkeydown" .

              var my1 = document.create EventObject(eve nt);
              my1.keyCode = 9;
              my1.shiftKey = true;
              event.srcElemen t.fireEvent("on "+event.type,my 1);
              event.keyCode = 0;
              event.returnVal ue=false;

              When I trace it, it does go to fireEvent. But it didn't work as shift+tab.

              Jack


              Comment

              Working...