1. Import
This commit is contained in:
216
html/sysadmin/keyTest.js
Normal file
216
html/sysadmin/keyTest.js
Normal file
@@ -0,0 +1,216 @@
|
||||
|
||||
<script language="JavaScript1.2" type="text/javascript">
|
||||
<!--
|
||||
// General functionality for all browsers in this section
|
||||
|
||||
// Hardcoding for enabling/disabling the event check for pressed keys
|
||||
var shiftKeyCheck = false;
|
||||
var controlKeyCheck = true;
|
||||
var altKeyCheck = true;
|
||||
|
||||
// Status of the event to be checked
|
||||
var shiftKeyIsPressed = false;
|
||||
var controlKeyIsPressed = false;
|
||||
var altKeyIsPressed = false;
|
||||
|
||||
var Netscape = new Boolean();
|
||||
Netscape = false;
|
||||
if (navigator.appName == "Netscape") Netscape = true;
|
||||
|
||||
// Status informations
|
||||
// document.write(navigator.appName + "<br>" + navigator.appVersion + "<br>" + navigator.appCodeName + "<br><br><br>");
|
||||
|
||||
|
||||
function disableEvent(e) {
|
||||
if (e.preventDefault) {
|
||||
if (e.cancelable) e.preventDefault();
|
||||
} else {
|
||||
e.keyCode = 0;
|
||||
e.returnValue = 0;
|
||||
e.cancelBubble = false;
|
||||
}
|
||||
/*
|
||||
if (Netscape) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
e.returnValue = false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
function handleEvent(e, pressedKey, keyCode) {
|
||||
window.status = "Taste " + pressedKey + " mit Dezimalwert " + keyCode + " gedrueckt";
|
||||
if (pressedKey == "SHIFT") {
|
||||
}
|
||||
|
||||
if (pressedKey == "CTRL") {
|
||||
|
||||
if (keyCode == "69") { // "e"
|
||||
alert("Z");
|
||||
disableEvent(e);
|
||||
top.menu.location.href = "../admin/menu.php";
|
||||
top.maincontent.location.href = "../jobs/job_edit.php";
|
||||
}
|
||||
}
|
||||
|
||||
if (pressedKey == "ALT") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//-->
|
||||
</script>
|
||||
|
||||
|
||||
<script language="JavaScript1.2" type="text/javascript">
|
||||
<!--
|
||||
// NETSCAPE 6 und MOZILLA FIREFOX
|
||||
|
||||
function eventKeyPressed(e)
|
||||
{
|
||||
if (Netscape) {
|
||||
|
||||
if (e.type == "keypress") {
|
||||
|
||||
// if (e.cancelable) e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (e.shiftKey) shiftKeyIsPressed = true;
|
||||
if (e.ctrlKey) controlKeyIsPressed = true;
|
||||
if (e.altKey) altKeyIsPressed = true;
|
||||
}
|
||||
|
||||
if (e.type == "keyup") {
|
||||
|
||||
if (e.cancelable) e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (e.shiftKey) shiftKeyIsPressed = false;
|
||||
if (e.ctrlKey) controlKeyIsPressed = false;
|
||||
if (e.altKey) altKeyIsPressed = false;
|
||||
}
|
||||
|
||||
if (e.type == "keydown") {
|
||||
|
||||
// window.status = "Taste mit Dezimalwert " + e.which + " gedrueckt";
|
||||
|
||||
if (shiftKeyCheck && shiftKeyIsPressed) {
|
||||
if (e.cancelable) e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleEvent(e,"SHIFT",e.which);
|
||||
shiftKeyIsPressed = false;
|
||||
|
||||
} else if (controlKeyCheck && controlKeyIsPressed) {
|
||||
if (e.cancelable) e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleEvent(e,"CTRL",e.which);
|
||||
controlKeyIsPressed = false;
|
||||
|
||||
} else if (altKeyCheck && altKeyIsPressed) {
|
||||
if (e.cancelable) e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleEvent(e,"ALT",e.which);
|
||||
altKeyIsPressed = false;
|
||||
|
||||
} else {
|
||||
handleEvent("",window.event.keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
this.focus();
|
||||
|
||||
return true;
|
||||
}; // if
|
||||
}; // function
|
||||
|
||||
// document.onkeydown = eventKeyPressed;
|
||||
// document.onkeyup = eventKeyPressed;
|
||||
// document.onkeypress = eventKeyPressed;
|
||||
if (Netscape) {
|
||||
document.addEventListener("keydown", eventKeyPressed, true);
|
||||
document.addEventListener("keyup", eventKeyPressed, true);
|
||||
document.addEventListener("keypress", eventKeyPressed, true);
|
||||
}
|
||||
|
||||
|
||||
// Get the string from the keyCode-number
|
||||
// String.fromCharCode(keyCode)
|
||||
|
||||
// http://webfx.eae.net/dhtml/ieemu/eventobject.html
|
||||
// Event.prototype.__defineSetter__("returnValue", function (b) {
|
||||
// if (!b) this.preventDefault();
|
||||
// );
|
||||
|
||||
// http://www.javascriptkit.com/jsref/event.shtml
|
||||
// Gegenüberstellung von Events IE und Netscape
|
||||
|
||||
// Disable help on F1
|
||||
// document.onhelp = function() { return false; }
|
||||
|
||||
|
||||
// http://www.quirksmode.org/js/events_early.html
|
||||
|
||||
// http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_event.asp
|
||||
|
||||
//-->
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- JScript-Bereiche fuer MS Internet Explorer -->
|
||||
<script for="document" event="onkeydown()" language="JScript" type="text/jscript">
|
||||
<!--
|
||||
{
|
||||
// window.status = "Taste mit Dezimalwert " + window.event.keyCode + " gedrueckt";
|
||||
|
||||
if (shiftKeyCheck && shiftKeyIsPressed) {
|
||||
window.event.returnValue = false;
|
||||
window.event.cancelBubble;
|
||||
handleEvent(window.event,"SHIFT",window.event.keyCode);
|
||||
shiftKeyIsPressed = false;
|
||||
|
||||
} else if (controlKeyCheck && controlKeyIsPressed) {
|
||||
window.event.returnValue = false;
|
||||
window.event.cancelBubble;
|
||||
handleEvent(window.event,"CTRL",window.event.keyCode);
|
||||
controlKeyIsPressed = false;
|
||||
|
||||
} else if (altKeyCheck && altKeyIsPressed) {
|
||||
window.event.returnValue = false;
|
||||
window.event.cancelBubble;
|
||||
handleEvent(window.event,"ALT",window.event.keyCode);
|
||||
altKeyIsPressed = false;
|
||||
|
||||
} else {
|
||||
handleEvent(window.event,"",window.event.keyCode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<script for="document" event="onkeyup()" language="JScript" type="text/jscript">
|
||||
<!--
|
||||
{
|
||||
if (window.event.shiftKey) shiftKeyIsPressed = false;
|
||||
if (window.event.ctrlKey) controlKeyIsPressed = false;
|
||||
if (window.event.altKey) altKeyIsPressed = false;
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<script for="document" event="onkeypress()" language="JScript" type="text/jscript">
|
||||
<!--
|
||||
{
|
||||
// window.event.returnValue = false;
|
||||
window.event.cancelBubble;
|
||||
|
||||
if (window.event.shiftKey) shiftKeyIsPressed = true;
|
||||
if (window.event.ctrlKey) controlKeyIsPressed = true;
|
||||
if (window.event.altKey) altKeyIsPressed = true;
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
Reference in New Issue
Block a user