View Full Version : how to detect user click the "numeric" button?

08-20-2002, 05:52 AM

i'm doing a calculator using Javascript, i want to detect user click on the numeric button from the keyboard. possible?
when user click "1" i will set the "button"(HTML) number 1 was clicked?

08-20-2002, 02:27 PM
if (navigator.appName == 'Netscape')

function checkKeys(e)
if (navigator.appName == 'Netscape')
theKey = e.which;
theKey = window.event.keyCode;
if ((thekey>=48&&theKey<=57)&&(thekey>=96&&theKey<=105)) {
key = String.fromCharCode(theKey);
alert("You Pressed: "+key)
alert("This is not a number");

You''ll need to play around with it a bit. Right now it filters out the numbers, but if you want them to be able to press * / - + = you'll need to add them in. You can also have them enter the text in a textbox, it would be much easier.

08-23-2002, 03:16 AM
this only work on Netscape? how about IE?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum