View Full Version : Conversions
db_rufus
08-08-2003, 07:50 AM
Is there any way in html or javascript to convert characters into ASCII code.
Vincent Puglia
08-08-2003, 10:19 AM
Hi,
the following works for IE & probably the rest of the newer browsers
<script>
function handler()
{
alert("Ascii code: " + event.keyCode
+ "\nkey hit: " + String.fromCharCode(event.keyCode))
}
document.onkeydown = handler
</script>
Vinny
db_rufus
08-08-2003, 12:07 PM
Thank you.
n8thegreat
08-08-2003, 12:22 PM
if you want it to work in others do
<script>
function handler( e )
{
e = e?e:event;
alert("Ascii code: " + e.keyCode
+ "\nkey hit: " + String.fromCharCode(e.keyCode))
}
document.onkeydown = handler
</script>
mozilla requires you to have the e in the function for some reason, you cant just access the event variable, its really annoying >:{
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.