O'Reilly logo

Beginning iOS Application Development with HTML and JavaScript® by Richard Wagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10

Handling Touch Interactions and Events

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • How to respond to basic touch events
  • How to respond to orientation event changes
  • How to customize key events

An essential part of any web application is the ability to respond to events triggered by the user or by a condition that occurs on the client: the clicking of a button, the pressing of a key, the scrolling of a window. Although the user interacts with an HTML element, the entire document, or the browser window, JavaScript serves as the watchful eye behind the scenes that monitors all of this activity taking place and fires off events as they occur.

With its touch interface, iPhone and iPad devices are all about direct interactivity with the user. As a result, it is not surprising that any IOS web app you create can handle the variety of gestures — finger taps, flicks, swipes, and pinches — that a user naturally performs as they interact with your app on their mobile device.

THREE TYPES OF TOUCH EVENTS

There are three primary types of touch-related events to consider when developing an IOS web app:

  • Mouse emulation events: Events in which a one- or two-finger action simulates a mouse.
  • Touch events: Events that dispatch when one or more fingers touch the screen. You can trap touch events and work with multiple finger touches that occur at different points on the screen at the same time.
  • Gesture events: Gesture events are combinations of touch events that also support scaling and rotation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required