Code: Alles auswählen.
<script language="JavaScript">
function getKeyCode(event) {
event = event || window.event;
return event.keyCode;
}
function showOutput(code)
{
Output=document.getElementById('show');
var text;
switch (code) {
case 112: text = "F1"; // F1
break;
case 113: text = "F2"; // F2
break;
case 114: text = "F3"; // F3
break;
case 115: text = "F4"; // F4
break;
case 116: text = "F5"; // F5
break;
case 117: text = "F6"; // F6
break;
case 118: text = "F7"; // F7
break;
case 119: text = "F8"; // F8
break;
case 120: text = "F9"; // F9
break;
case 121: text = "F10"; // F10
break;
case 122: text = "F11"; // F11
break;
case 123: text = "F12"; // F12
break;
}
if(!text) text = String.fromCharCode(code);
Output.firstChild.nodeValue=text;
self.focus();
}
document.onkeypress = function()
{
return false;
}
document.onkeydown = function(event){
var charCode = getKeyCode(event);
showOutput(charCode);
return false;
}
</script>
<body>
PRESS ANY KEY TO KONTINÜ<br>
Anzeige der gewählten Taste:
<b>
<p id="show">
</p>
</b>
</body>
Code: Alles auswählen.
<script language="JavaScript">
function getKeyCode(event) {
event = event || window.event;
return event.keyCode;
}
function showOutput(code){
switch (code) {
case 112:
document.eins.submit(); // F1
break;
}
document.onkeypress = function(){
return false;
}
document.onkeydown = function(event){
var charCode = getKeyCode(event);
showOutput(charCode);
return false;
}
</script>
<form name="eins" action="handle-data.php">
das ist ein test... <input type="text">
</form>
Code: Alles auswählen.
LAYOUT:
<head>
...
# Ruft bei Tastendruck die Funktion myHandler auf #
<script for=document event="onkeypress()" language="JScript">{myHandler();}</script>
<script for=document event="onkeydown()" language="JScript">{myHandler();}</script>
<script for=document event="onkeyup()" language="JScript">{myHandler();}</script>
...
<script language="JScript"> function myHandler(){
#Handler für das Drücken der linken Cursortaste
if (window.event.keyCode == "37"){
var dir = "links";
# übergibt dem Hidden Field "Key" einen Wert
document.RF.key.value = dir;
# Submit des Formulars RF
document.RF.submit();}
return false;}
</script>
...
</head>
<body>
...
<form name="RF">
...
<input type="hidden" name="key" value ="">
...
</form>
<body>
Code: Alles auswählen.
ONMANIPULATION:
IF key EQ 'links'.
* mach deine Aktionen für die linke Cursortaste
ENDIF.