On 18 mayo, 11:52, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Thomas 'PointedEars' Lahn wrote:
var charCode = (typeof e.charCode != "undefined"
? e.charCode
: (typeof e.keyCode != "undefined"
? e.keyCode
: charCode);
: charCode));
This is the test page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!-- Keyboard events test program, by Joaquín Zuazo -->
<head>
<title>Testing keyboard events</title>
<meta http-equiv="encoding=UTF-8"></meta>
<script language="javascript" type="text/javascript">
window.onload=testkeys;
var checkinput, out;
var title = "Event\t\tkeyCode\t\twhich\t\tcharCode\tfromCharCo de
\tInput Box\n\n";
function testkeys()
{
checkinput = document.getElementById("checkinput");
out = document.getElementById("out");
out.innerHTML = title;
checkinput.onkeydown=check_down;
checkinput.onkeypress=check_press;
checkinput.onkeyup=check_up;
}
function reset_all()
{
out.innerHTML = title;
checkinput.value ="";
}
function output_message(function_name,event)
{
var valid_one = event.keyCode ? event.keyCode : event.which ?
event.which : event.charCode;
var message = function_name + "\t"
+ ( event.keyCode ? event.keyCode : event.keyCode == 0 ?
0 : "undef" )
+ "\t\t"
+ ( event.which ? event.which : event.wich == 0 ?
0 : "undef" )
+ "\t\t"
+ ( event.charCode ? event.charCode : event.charCode == 0 ?
0 :"undef" )
+ "\t\t"
+ ( valid_one >= 32 ? String.fromCharCode ( valid_one ) :
"Ctrl" )
+ "\t\t"
+ checkinput.value
+ "\n";
out.innerHTML += message;
}
function check_press(e)
{
var event = e ? e : window.event;
output_message("keypress",event);
}
function check_up(e)
{
var event = e ? e : window.event;
output_message("keyup ",event);
}
function check_down(e)
{
var event = e ? e : window.event;
output_message("keydown ",event);
}
</script>
</head>
<body>
<h1>Testing keyboard events</h1>
<button onclick="reset_all();">Reset </button>
<input id="checkinput"></input>
<pre id="out"</pre>
</body>
</html>
This is the result for the key sequence 'a on Linux, Firefox 2.0.0.14
Event keyCode which charCode fromCharCode Input Box
keyup 0 undef 0 Ctrl
keyup 65 65 0 A á
And this is the result with Firefox 2.0.0.14 on Windows Xp
Event keyCode which charCode fromCharCode Input Box
keydown 222 222 0 Þ
keyup 222 222 0 Þ
keydown 65 65 0 A
keypress 0 225 225 á
keyup 65 65 0
A á
Do you think is this a bug of Firefox?
The problem is that the only place where is kept valid information
with the Linux implementation
is inside the input text box, and hacking this is somewhat dirty.
I really thank any suggestion