1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

onkeypress help.

Discussion in 'Web Design & Development' started by j00m3h, Feb 9, 2005.

Thread Status:
Not open for further replies.
Advertisement
  1. j00m3h

    j00m3h Thread Starter

    Joined:
    Feb 9, 2005
    Messages:
    3
    What I'm looking to do is have it so when I press the left arrow key, it goes to a certain website. I tried this a while back and it wouldn't work since where I'm trying to use it, it redirects to the login page if you just type in a link.

    The only way I know of is onkeypress in javascript, so yeah. *edit I wanted to do it from the arrow keys, and I'm not sure if I can from onkeypress. Maybe onkeydown? Not sure. *

    I was thinking of this, and since I'm able to do it like this with other things, I figured it work for this too so I figured I'd try it. Since I just can't have it go straight to the site, is there a way that I can have it submit this form when the key is pressed?

    <form action="shared.fcgi" method="post"><input type="hidden" name="email" value="[email protected]"><input type="hidden" name="pass" value=""><input type="hidden" name="step" value="page245"><input type="hidden" name="other" value="195617"><input type="hidden" name="fu" value="1"><input type="submit" name="left" value="Click this button"></form>

    So that once the key is pressed it just does that form? Anyone know?
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    <a href="website address"><image src="image of button"></a>
     
  3. j00m3h

    j00m3h Thread Starter

    Joined:
    Feb 9, 2005
    Messages:
    3
    ...that isn't what I asked for? :confused:
     
  4. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    I know, but from your descrition it was kind of hard to decipher.

    "I press the left arrow key , it goes to a certain website" Arrow key on the keyboard, left mouse button??? There is such a thing as access key for performing actions but I don't think the arrow keys are part of the charachter set.
     
  5. j00m3h

    j00m3h Thread Starter

    Joined:
    Feb 9, 2005
    Messages:
    3
    They are, and I figured it out. If anyone's interested...

    Code:
     
    <script language="javascript" type="text/javascript"> 
    <!-- 
              document.onkeydown = function keyPress(evt) 
                   { 
                   var keyCode = 
                   document.layers ? evt.which : 
                   document.all ? event.keyCode : 
                   document.getElementById ? evt.keyCode : 0; 
                   if (keyCode == 37) 
                        {__doPostBack(document.location="URL1",'')} 
                   if (keyCode == 38) 
                        {__doPostBack(document.location="URL2",'')}
    	       if (keyCode == 39) 
                        {__doPostBack(document.location="URL3",'')} 
                   if (keyCode == 40) 
                        {__doPostBack(document.location="URL4",'')} 
    
     
                   } 
              //--> 
              </script> 
    
    That is to have it go to 4 different sites when pushing the up down left right arrows on the KEYBOARD. I just need to figure out how to make it submit a form instead now. Anyone know?
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/328400

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice