Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keyboard shortcuts with JavaScript
#6
I see your point...
Well this is how I would do it with ordinary javascript.

Code:
<!DOCTYPE html>
    <head>
        <title>{$TITLE}</title>
        <link rel="stylesheet" type="text/css" href="style/main.css" />
        <script src="http://code.jquery.com/jquery-1.5.js" type="text/javascript"></script>
        <script type="text/javascript">
            var pages = {
                0:"index.htm",
                1:"1.php",
                2:"2.php",
                3:"3.php",
                4:"4.php",
            };
            
            var page = 0;
            
            function keydown(e)
            {
                e = (e) ? e : window.event;
                var key = (e.charCode) ? e.charCode : e.keyCode;
                if(key == 37)
                {
                    page = (page > 0) ? (page - 1) : 0;
                }
                else if(key == 39)
                {
                    page = (page < 4) ? (page + 1) : 4;
                }
                
                window.location = pages[page];
            }
        </script>
        <!--[if IE 8]><link rel="stylesheet" href="style/ie.css" /><![endif]-->
        <!--[if IE 7]><link rel="stylesheet" href="style/ie.css" /><![endif]-->
        <!--[if IE 6]><link rel="stylesheet" href="style/ie.css" /><![endif]-->
    </head>
    <body onload="" onkeydown="keydown(event)">
    </body>
</html>

In this script you need to remember, the javascript code needs to be loaded in every other file that your redirect the user to, and you need to update the page variable with PHP for example, or simply assign the right number to it in every file.
Reply


Messages In This Thread
RE: Keyboard shortcuts with JavaScript - by Gaijin - 04-15-2011, 01:12 PM
RE: Keyboard shortcuts with JavaScript - by Gonzo - 04-18-2011, 07:10 PM
RE: Keyboard shortcuts with JavaScript - by Danny - 05-07-2011, 01:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Free Worker HTML, CSS, Javascript ImFocuzz 2 1,281 04-05-2014, 10:01 PM
Last Post: VHPanda
  [MyBBError Message] PLEASE HELP ME!! Enable Javascript Registration Error iRun 4 1,921 01-26-2012, 03:13 PM
Last Post: iRun
  Close Tab With Javascript. Qua 3 1,410 07-02-2011, 07:25 AM
Last Post: djakariuz
  Javascript Help. Form Submission. JohnRonder 0 890 02-01-2011, 11:12 AM
Last Post: JohnRonder
  [javascript] Link of Minute zone 3 1,093 12-11-2009, 02:16 AM
Last Post: Sagittarius

Forum Jump:


Users browsing this thread: 8 Guest(s)