You are here: onKeyPress question « HTML « IT news, forums, messages
onKeyPress question

Posted by Eric on 10/02/05 20:07

I have a little html calculator form that I've been playing with, you click
the buttons to enter data and operators. I wanted to add the ability to
also press keys instead of only being able to click on buttons.
here's a portion of what i have.

<div style="text-align:center">
<input id="display" style="width:120;text-align:right" readonly>
<br>
<input type="button" value=" 1 " onClick="display.value += '1'">
<input type="button" value=" 2 " onClick="display.value += '2'">
<input type="button" value=" 3 " onClick="display.value += '3'">
etc etc
<input type="button" value=" . " onClick="display.value += '.'">
<input type="button" value=" C " onClick="display.value = ''">
<br>
<input type="button" value=" x " onClick="display.value += ' x '">
<input type="button" value=" / " onClick="display.value += ' / '">
<input type="button" value=" - " onClick="display.value += ' - '">
<input type="button" value=" + " onClick="display.value += ' + '">
<br>
<input type="button" value=" sqrt " onClick="display.value =
Math.sqrt(display.value)">
<input type="button" value=" = " onClick="display.value =
eval(display.value)">
</div>

How do i add the onKeyPress so that both clicking and typing work?
Thanks
Eric

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация