jumping cursor using Keyboard

This commit is contained in:
Michal Čihař
2003-01-14 13:01:02 +00:00
parent 99f08d6111
commit d2ed8f4eaa
3 changed files with 51 additions and 8 deletions

View File

@@ -478,3 +478,39 @@ function setSelectOptions(the_form, the_select, do_check)
return true;
} // end of the 'setSelectOptions()' function
/**
* Allows moving around inputs/select by Ctrl+arrows
*
* @param object event data
*/
function onKeyDownArrowsHandler(e) {
e=e||window.event;
var o = (e.srcElement||e.target);
if (!o) return;
if (o.tagName != "INPUT" && o.tagName != "SELECT") return;
if (!e.ctrlKey) return;
if (!o.id) return;
var pos = o.id.split("_");
if (pos[0] != "field" || typeof pos[2] == "undefined") return;
var x = pos[2], y=pos[1];
switch(e.keyCode) {
case 38: y--; break; // up
case 40: y++; break; // down
case 37: x--; break; // left
case 39: x++; break; // right
default: return;
}
var id = "field_" + y + "_" + x;
var nO = document.getElementById(id);
if (!nO) return;
nO.focus();
if (nO.tagName != 'SELECT') {
nO.select();
}
e.returnValue = false;
}