J
J. J. Cale
Hi
The code below worked fine in IE5. I changed to IE6 and I can trap the
'enter' key but I can't add a line feed to the text in the div. Also what
other browser should I be testing with and where can I download it? I intend
to write a full blown kbd handler that will also trap the backspace and tab
etc. I can use all the help I can get. BTW I tried doing this with a
textarea but I need to write directly to the divide. The intention here is
to have a letter that can have different borders clipart etc and the ability
to select text and change the various css properties or use exec Command to
toggle them. If anyone has this working or knows of someone or a site that
has I'll be ecstatic.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>kbd handler</TITLE>
<script type="text/javascript">
document.onkeypress = function (evt) {
var el = document.all?letter:document.getElementById('letter');
var evt = evt || window.event;
var keyCode = evt.keyCode || evt.which;
// alert(keyCode);
if(keyCode == 27) return;
if(keyCode == 13) {
el.firstChild.data += '\n';
el.innerText += '\n';
el.innerHTML += '<br>';
return;
}
var str = String.fromCharCode(keyCode);
// el.firstChild.data += str;
el.innerText += str;
}
</script></HEAD>
<BODY>
<div id="letter"
style="width:300px;padding:4px;margin-left:4px;height:450px;background-color
:#ffffcc;"></div>
</BODY></HTML>
TIA
Jimbo
The code below worked fine in IE5. I changed to IE6 and I can trap the
'enter' key but I can't add a line feed to the text in the div. Also what
other browser should I be testing with and where can I download it? I intend
to write a full blown kbd handler that will also trap the backspace and tab
etc. I can use all the help I can get. BTW I tried doing this with a
textarea but I need to write directly to the divide. The intention here is
to have a letter that can have different borders clipart etc and the ability
to select text and change the various css properties or use exec Command to
toggle them. If anyone has this working or knows of someone or a site that
has I'll be ecstatic.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>kbd handler</TITLE>
<script type="text/javascript">
document.onkeypress = function (evt) {
var el = document.all?letter:document.getElementById('letter');
var evt = evt || window.event;
var keyCode = evt.keyCode || evt.which;
// alert(keyCode);
if(keyCode == 27) return;
if(keyCode == 13) {
el.firstChild.data += '\n';
el.innerText += '\n';
el.innerHTML += '<br>';
return;
}
var str = String.fromCharCode(keyCode);
// el.firstChild.data += str;
el.innerText += str;
}
</script></HEAD>
<BODY>
<div id="letter"
style="width:300px;padding:4px;margin-left:4px;height:450px;background-color
:#ffffcc;"></div>
</BODY></HTML>
TIA
Jimbo