Keydown, keypressed? input without inputbox

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

    #1

    Keydown, keypressed? input without inputbox

    Hi,

    I recently saw on a website, that there was a possibility that when
    you're on a certain webpage,

    and you type like " code " on your keyboard, that some function is
    being called.
    Does anyone has experience with this?

    Cause i would really like some help..

    I would like on a page, when typing " admin " that your current window
    is being redirected to another page.

    Like i have my html page. i type " google " and suddently i'm
    redirected to www.google.com. The thing is, you don't see what you
    type. Thats the whole idea behind this.

    I hope people understand me,

    Thanks in advance

  • Randy Webb

    #2
    Re: Keydown, keypressed? input without inputbox

    Shirenseru said the following on 5/11/2006 5:29 AM:[color=blue]
    > Hi,
    >
    > I recently saw on a website, that there was a possibility that when
    > you're on a certain webpage,
    >
    > and you type like " code " on your keyboard, that some function is
    > being called.
    > Does anyone has experience with this?[/color]

    onkeydown/up on the window object.
    [color=blue]
    > Cause i would really like some help..
    >
    > I would like on a page, when typing " admin " that your current window
    > is being redirected to another page.[/color]

    That's counter-intuitive.
    [color=blue]
    > Like i have my html page. i type " google " and suddently i'm
    > redirected to www.google.com. The thing is, you don't see what you
    > type. Thats the whole idea behind this.[/color]

    And if you type it wrong?

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Shirenseru

      #3
      Re: Keydown, keypressed? input without inputbox

      Well i mean when you type

      " adm " and then " p "

      it should break. But when the followup is " admin " only then, the
      page should open www.google.com

      could you give me an example?

      Comment

      • Shirenseru

        #4
        Re: Keydown, keypressed? input without inputbox

        Hey i got it!

        http://webdeveloper.earthweb.com/web...tem.php/822271

        this was what i meant.

        but instead of that msgbox i want to open a link in the same window.

        Comment

        • Vic Sowers

          #5
          Re: Keydown, keypressed? input without inputbox


          "Shirenseru " <silencer116@ho tmail.com> wrote in message
          news:1147340626 .947072.77740@v 46g2000cwv.goog legroups.com...[color=blue]
          > Well i mean when you type
          >
          > " adm " and then " p "
          >
          > it should break. But when the followup is " admin " only then, the
          > page should open www.google.com
          >
          > could you give me an example?
          >[/color]

          Try something like:

          <body onKeyPress="Mon itorTyping()">
          <h1>Blind Entry Test</h1>
          <script type="text/JavaScript" defer>
          buffer="";
          function MonitorTyping() {
          buffer = (buffer+String. fromCharCode(ev ent.keyCode)).s lice(-10);
          if (buffer.slice(-4)=="admp") document.locati on = "http://Yahoo.com";
          if (buffer.slice(-5)=="admin") document.locati on = "http://Google.com";
          }
          </script>
          </body>


          Comment

          • ASM

            #6
            Re: Keydown, keypressed? input without inputbox

            Vic Sowers a écrit :[color=blue]
            > "Shirenseru " <silencer116@ho tmail.com> wrote in message
            > news:1147340626 .947072.77740@v 46g2000cwv.goog legroups.com...
            >[color=green]
            >>Well i mean when you type
            >>
            >>" adm " and then " p "
            >>
            >>it should break. But when the followup is " admin " only then, the
            >>page should open www.google.com
            >>
            >>could you give me an example?
            >>[/color]
            >
            >
            > Try something like:[/color]

            this bellow works in my FireFox

            <body>
            <h1>Blind Entry Test</h1>

            <script type="text/JavaScript">
            buffer = "";
            onkeyup = MonitorTyping;
            function MonitorTyping(e ) {
            e = e || event;
            buffer += String.fromChar Code(e.keyCode) .toLowerCase();
            if (buffer.indexOf ("admp")>=0) location = "http://Yahoo.com";
            if (buffer.indexOf ("admin")>=0 ) location = "http://Google.com";
            </script>

            </body>
            </html>


            --
            Stephane Moriaux et son [moins] vieux Mac

            Comment

            • Randy Webb

              #7
              Re: Keydown, keypressed? input without inputbox

              Shirenseru said the following on 5/11/2006 5:50 AM:

              Please quote what you are replying to.

              If you want to post a followup via groups.google.c om, don't use the
              "Reply" link at the bottom of the article. Click on "show options" at
              the top of the article, then click on the "Reply" at the bottom of the
              article headers.

              <URL: http://www.safalra.com/special/googlegroupsreply/ >
              [color=blue]
              > Hey i got it!
              >
              > http://webdeveloper.earthweb.com/web...tem.php/822271
              >
              > this was what i meant.
              >
              > but instead of that msgbox i want to open a link in the same window.
              >[/color]

              Change this line of code:

              var code = "code"; //no spaces no special chars

              To something like this:

              var code="admin";

              And then, change this line of code:

              alert("You typed the code!")

              to this:

              window.location = 'http://www.google.com/';

              --
              Randy
              comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
              Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

              Comment

              Working...