Home arrow HTML arrow More on the Keyboard for a Web Page Calculator

More on the Keyboard for a Web Page Calculator

In this fifth part of a six-part series on building a web page calculator, we shall see how to use the keyboard with the calculator. The event involved is the onkeypress event, which we saw in the last part of the series. For an element to respond to the event, it has to have focus. With some browsers, if all of the elements that have to respond to the keyboard have the same function, and are in the same group (on the calculator), you only have to give one of the elements focus. This is the case with my browser.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
April 01, 2009
  1. · More on the Keyboard for a Web Page Calculator
  2. · The processKey(e) Function
  3. · Details of the processKey(e) Code segments
  4. · The Second if (else if) block
  5. · The Fourth if (else if) block

print this article

More on the Keyboard for a Web Page Calculator
(Page 1 of 5 )

Modifying the Initialization Function

The initialization function is the showCalc() function. When the web page is opened, and you click the Use Calculator button, this function is called. The function opens the calculator and does any initialization necessary. The only initialization it has to do is give focus to the zero digit button. So add the following line at the bottom of the showCalc() function.


Handling Keyboard Presses

When you press any key on the keyboard, the function processKey(e) is called. This function is added to do all the processing of keyboard issues.

blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials