#1
  1. No Profile Picture
    webgeek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    Dallas, TX, USA
    Posts
    120
    Rep Power
    12

    capturing F-Keys with JSP


    Is is possible to capture the pressing of F-Keys in JSP?

    Our legacy apps use F-Keys frequently for keyboard shortcuts and we would like to continue their use while converting from 5250 to JSP.

    If so, where could we find a sample to learn from?

    Thanks.
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Well, since JSP is server-side, no. If you want to try javascript, then yes, but you have to be using mozilla (or other gecko browser). Be aware that many F-keys have a meaning to the browser (such as F5 for refresh), so you have to keep the browser from seeing the keypress. Here's some code that works for F1-F12, with the notable exception of F7, which Mozilla Firebird won't ignore.

    Code:
    <html>
    <head>
    	<script type="text/javascript">
    		window.onkeypress = function( e ) {
    			switch( e.keyCode ) {
    				case 112:
    					alert( 'F1' );
    					break;
    				case 113:
    					alert( 'F2' );
    					break;
    				case 114:
    					alert( 'F3' );
    					break;
    				case 115:
    					alert( 'F4' );
    					break;
    				case 116:
    					alert( 'F5' );
    					break;
    				case 117:
    					alert( 'F6' );
    					break;
    				case 118:
    					alert( 'F7' );
    					break;
    				case 119:
    					alert( 'F8' );
    					break;
    				case 120:
    					alert( 'F9' );
    					break;
    				case 121:
    					alert( 'F10' );
    					break;
    				case 122:
    					alert( 'F11' );
    					break;
    				case 123:
    					alert( 'F12' );
    					break;
    				default:
    					//ignore it. not an Fkey
    					return true;
    			}
    			//try to prevent the browser from getting the input
    			return false;
    		}
    	</script>
    </head>
    <body>
    	Press a key, any key, but especially an F-key!
    </body>
    </html>
    If you want to continue exploring this, I'd suggest you go start another thread in the HTML, Javascript, and CSS forum to get some refinement. You're going to need a way to get the javascript funtion to comunicate with your JSP.
    -james

IMN logo majestic logo threadwatch logo seochat tools logo