SlideShare una empresa de Scribd logo
1 de 57
Descargar para leer sin conexión
Hell is other browsers - Sartre


    The touch events

        Peter-Paul Koch (ppk)
      http://quirksmode.org
      http://twitter.com/ppk
WebExpo, 24 September 2010
The desktop web
Boring!

-   Only five browsers
-   with only one viewport each
-   that support nearly everything
-   Even IE? Yes, even IE.
The Mobile Web
Exciting!

- Fifteen browsers and counting
- ranging from great to lousy
- Interesting new bugs
- About five times as many users as the
  desktop web (eventually)
- New interaction modes
The Mobile Web
Exciting!

- Fifteen browsers and counting
- ranging from great to lousy
- Interesting new bugs
- About five times as many users as the
  desktop web (eventually)
- New interaction modes
Mobile browsers
-   Android WebKit      -   NetFront
-   Opera Mobile        -   Bolt
-   Dolfin (bada)       -   UCWeb
-   Safari              -   Obigo
-   MicroB              -   Fennec
-   BlackBerry WebKit   -   Opera Mini
-   Symbian WebKit
-   IE Mobile
-   Palm WebKit
You may groan now.
Mobile browsers
-   Android WebKit        -   NetFront
-   Opera Mobile          -   Bolt
-   Dolfin (bada)         -   UCWeb
-   Safari                -   Obigo
-   MicroB                -   Fennec
-   BlackBerry WebKit     -   Opera Mini
-   Symbian WebKit
-   IE Mobile
-   Palm WebKit
These are all WebKit-based.
WebKit Mobile
There is no WebKit on Mobile.
There's iPhone Safari (3 and 4),
and Android (1.6 and 2.1 and 2.2)
and Symbian WebKit (1 and 2)
and Blackberry WebKit
and Palm WebKit
and Dolfin for bada


These WebKits are all different.
There is no WebKit on Mobile.
http://quirksmode.org/webkit.html
Mobile web dev
Focus on (in roughly this order)
- iPhone
- Android
- BlackBerry (WebKit and old)
- Symbian WebKit
- Opera Mini
- Opera Mobile
- Dolfin (bada)
Mobile web dev
Focus on (in roughly this order)
- iPhone
- Android
- BlackBerry (WebKit and old)
- Symbian WebKit
- Opera Mini
- Opera Mobile
- Dolfin (bada)
Opera Mobile and Mini
Opera Mobile is a normal browser.
Request HTML, CSS, and JavaScript,
interpret and execute them.

Opera Mini, though, sends your request
to a special server,
which requests the HTML, CSS, and JS
then interprets it
and sends back basically a bitmap
Opera Mini
Opera Mini advantages:
- Little memory necessary, works on old
  phones, too.
- Less network traffic: you receive a
  highly compressed bitmap
Opera Mini
Opera Mini disadvantage:
- No client-side interactivity. If a click
  event fires, Opera Mini goes back to
  the server to ask for instructions

Tradeoff: lose client-side interactivity,
but spend less money on devices and
network connections.
Mobile web dev
Focus on (in roughly this order)
- iPhone
- Android
- BlackBerry (WebKit and old)
- Symbian WebKit
- Opera Mini
- Opera Mobile
- Dolfin (bada)
Mobile web dev
Get real devices to test on.
- iPhone or Android
- Nokia S60
- BlackBerry (older)
- Windows Mobile (useful secondary test
  platform)

Yes, that's expensive.
It's also necessary.
Mobile web dev
Get real devices to test on.

- Unlocked! You should test with
  multiple networks
- or with wifi
Mobile web dev
Use testing services:

http://www.deviceanywhere.com/
http://perfectomobile.com/

Or use an emulator. Most mobile phone
vendors offer one.
Drawback: you can't hold them in your
hand, and that's crucial for mobile.
The Mobile Web
Exciting!

- Fifteen browsers and counting
- ranging from great to lousy
- Interesting new bugs
- About five times as many users as the
  desktop web (eventually)
- New interaction modes
Before we start
please open the following link on your
phone:

http://quirksmode.org/touchevents

It gives links to the test files.
The touch tests only work on iPhone,
Android, bada, and BlackBerry Torch.
Mouse
Mouse




Keyboard
Mouse




Keyboard




Touch
Keyboard users need different Mouse
interaction than mouse users
need different interactions than touch
users.

Your script accomodates all three
modes, right?

It's all a question of events.
keydown
keypress
keyup
mouseover
mouseout
mousedown
mouseup
mousemove
touchstart
touchmove
touchend
touchcancel
It's not an either-or proposition.
It's not an either-or proposition.

                         The Nokia E71
                         has a four-way
                         navigation.
                         Works like the
                         arrow keys
                         (including
                         keycodes).

                         But...
It's not an either-or proposition.

                         But...
                         the “arrow keys”
                         steer a mouse
                         cursor.

                         Key events
                         and mouse
                         events
Today we'll concentrate on the touch
events, though.
http://quirksmode.org/touchevents

Open the first dropdown example.

Task: Click on option 3.2

This is with traditional mouseover and
mouseout; no touch-specific code.
Works (a bit oddly, but works).
In theory a touchscreen device should
fire only the touch events, and not the
mouse events.

A touchscreen device doesn't have a
mouse, after all.

However, too many websites depend on
the mouse events, so touch browser
vendors are forced to support them,
too.
Touch !== mouse
-   Area
-   Pressure
-   Temperature
-   more than one touch
http://quirksmode.org/touchevents

Now open the second dropdown
example.

Task: Click on option 3.2

Doesn't work.
Not an entirely fair comparison.

Touchstart and touchend are not the
equivalents of mouseover and
mouseout.

In fact, true hovering is impossible on
touchscreens.
There is no way of saying “I might be
interested in this element but I'm not
sure yet.”
Interaction modes
Mouse       Keyboard Touch
mousedown   keydown    touchstart
mousemove   keypress   touchmove
mouseup     keyup      touchend
mouseover   focus      -
mouseout    blur       -
All         All        iPhone,
                       Android, bada,
                       BlackBerry
Interaction modes
Mouse         Keyboard Touch
mousedown     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
load, unload, click, submit, resize,
zoom, change etc. etc.
Interaction modes
Mouse         Keyboard Touch
mousedown     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
load, unload, click, submit, resize,
zoom, change etc. etc.
Interaction modes
Mouse         Keyboard Touch
mousedown     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
load, unload, click, submit, resize,
zoom, change etc. etc.
Interaction modes
Mouse         Keyboard Touch
mousedown     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
load, unload, click, submit, resize,
zoom, change etc. etc.
When you touch the screen of a
touchscreen, both touch and mouse
events fire.

But the mouse events are a bit special.
They all fire at the same time.

http://quirksmode.org/touchevents

You can test the events for yourself at
the touch action test page.
touchstart
mouseover
mousemove (only one!)
mousedown
mouseup
click
:hover styles applied
Once started, the touch events keep
firing regardless of where your finger is.

element.ontouchmove = function () {
  // do stuff
}

This event handler continues firing even
if your finger leaves the element.

We need touchenter and touchleave
events for when finger enters or leaves
element.
touchstart      If a DOM change occurs
mouseover       onmouseover or
mousemove       onmousemove, the rest
mousedown       of the events is cancelled.
mouseup         (iPhone and Symbian)
click
:hover styles   applied
When the user touches another element
mouseout
:hover styles removed
http://quirksmode.org/touchevents

Try the Event Delegation page. Touch
the bordered div.

document.onclick = function () {
  // change divs
}

You click on a div, not on the document.
Still, the event bubbles up.
Except on the iPhone.
The iPhone does not register a click
event if the element you click on doesn't
have a click event handler.

document.onclick = function () {
  // change divs
}
div.onclick = function () {}

Now the div itself has a click event
handler, and event delegation works
fine.
http://quirksmode.org/touchevents

Now open the first drag-and-drop
example.

Should work fine; both on touch devices
and with a mouse.

This is very simple.
Mouse and touch events:

element.ontouchstart = function (e) {
  element.ontouchmove = function (e) {etc}
  element.ontouchend = function (e) {etc}

}
element.onmousedown = function (e) {
  document.onmousemove = function (e) {etc}
  document.onmouseup = function (e) {etc}
}
Mouse and touch events:

element.ontouchstart = function (e) {
  element.ontouchmove = function (e) {etc}
  element.ontouchend = function (e) {etc}
  element.onmousedown = null;
}
element.onmousedown = function (e) {
  document.onmousemove = function (e) {etc}
  document.onmouseup = function (e) {etc}
}


But how do you know whether to use the
mouse or the touch events?
http://quirksmode.org/touchevents

Now open the second drag-and-drop
example.

iPhone only.
Try dragging two or all three layers
simultaneously.
(A bit stilted, but you get the point.)
This is impossible on a desktop
computer. Two mice?

Useful for games, maybe (especially on
the iPad).

Does not work on other browsers: they
don't (yet) support true multitouch.
http://quirksmode.org/touchevents

Now open the scrolling layer example.

Works fine – on mobile.
But how do we port this to the other
interaction modes?
- keys: use arrow keys
- mouse: ???
Interaction modes

-   mouse
-   keyboard
-   touch
-   and a fourth....
Interaction modes

-   mouse
-   keyboard
-   touch
-   trackball

Generally fires a
mousemove event
Thank you!
       Questions?
http://quirksmode.org
http://twitter.com/ppk

I'll post these slides on my site.

Más contenido relacionado

La actualidad más candente

Voices That Matter: JavaScript Events
Voices That Matter: JavaScript EventsVoices That Matter: JavaScript Events
Voices That Matter: JavaScript EventsPeter-Paul Koch
 
Wii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoWii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoLittleBIGRuby
 
Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...Patrick Lauke
 
Intro to Google TV
Intro to Google TVIntro to Google TV
Intro to Google TVGauntFace
 
Android UI Reference
Android UI ReferenceAndroid UI Reference
Android UI ReferenceGauntFace
 
Flash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic listFlash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic listSmall Screen Design
 

La actualidad más candente (6)

Voices That Matter: JavaScript Events
Voices That Matter: JavaScript EventsVoices That Matter: JavaScript Events
Voices That Matter: JavaScript Events
 
Wii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoWii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont Do
 
Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...
 
Intro to Google TV
Intro to Google TVIntro to Google TV
Intro to Google TV
 
Android UI Reference
Android UI ReferenceAndroid UI Reference
Android UI Reference
 
Flash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic listFlash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic list
 

Similar a Mobile Browser Events - Supporting Touch, Mouse and Keyboard

Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Patrick Lauke
 
Fast multi touch enabled web sites
Fast multi touch enabled web sitesFast multi touch enabled web sites
Fast multi touch enabled web sitesAspenware
 
Tips for building fast multi touch enabled web sites
 Tips for building fast multi touch enabled web sites Tips for building fast multi touch enabled web sites
Tips for building fast multi touch enabled web sitesAspenware
 
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Patrick Lauke
 
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013Patrick Lauke
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhoneErin Dees
 
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...Patrick Lauke
 
Getting touchy - an introduction to touch and pointer events / Web Rebels / O...
Getting touchy - an introduction to touch and pointer events / Web Rebels / O...Getting touchy - an introduction to touch and pointer events / Web Rebels / O...
Getting touchy - an introduction to touch and pointer events / Web Rebels / O...Patrick Lauke
 
Patrick H. Lauke - Getting Touchy; an introduction to touch and pointer events
Patrick H. Lauke - Getting Touchy; an introduction to touch and pointer eventsPatrick H. Lauke - Getting Touchy; an introduction to touch and pointer events
Patrick H. Lauke - Getting Touchy; an introduction to touch and pointer eventsDevConFu
 
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013Patrick Lauke
 
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...Patrick Lauke
 
T3con10_html5_kosack_zinner
T3con10_html5_kosack_zinnerT3con10_html5_kosack_zinner
T3con10_html5_kosack_zinnerRobert Zinner
 
Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...Patrick Lauke
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesEthan Cha
 
CSS for Touch Devices
CSS for Touch DevicesCSS for Touch Devices
CSS for Touch DevicesEmma Woods
 
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...Patrick Lauke
 
Win7 Multi Touch
Win7 Multi TouchWin7 Multi Touch
Win7 Multi TouchDaniel Egan
 
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...Patrick Lauke
 
Understanding the Touch Interface [IndicThreads Mobile Application Developmen...
Understanding the Touch Interface [IndicThreads Mobile Application Developmen...Understanding the Touch Interface [IndicThreads Mobile Application Developmen...
Understanding the Touch Interface [IndicThreads Mobile Application Developmen...IndicThreads
 

Similar a Mobile Browser Events - Supporting Touch, Mouse and Keyboard (20)

The touch events
The touch eventsThe touch events
The touch events
 
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
 
Fast multi touch enabled web sites
Fast multi touch enabled web sitesFast multi touch enabled web sites
Fast multi touch enabled web sites
 
Tips for building fast multi touch enabled web sites
 Tips for building fast multi touch enabled web sites Tips for building fast multi touch enabled web sites
Tips for building fast multi touch enabled web sites
 
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
 
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
 
Getting touchy - an introduction to touch and pointer events / Web Rebels / O...
Getting touchy - an introduction to touch and pointer events / Web Rebels / O...Getting touchy - an introduction to touch and pointer events / Web Rebels / O...
Getting touchy - an introduction to touch and pointer events / Web Rebels / O...
 
Patrick H. Lauke - Getting Touchy; an introduction to touch and pointer events
Patrick H. Lauke - Getting Touchy; an introduction to touch and pointer eventsPatrick H. Lauke - Getting Touchy; an introduction to touch and pointer events
Patrick H. Lauke - Getting Touchy; an introduction to touch and pointer events
 
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
 
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
 
T3con10_html5_kosack_zinner
T3con10_html5_kosack_zinnerT3con10_html5_kosack_zinner
T3con10_html5_kosack_zinner
 
Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And Types
 
CSS for Touch Devices
CSS for Touch DevicesCSS for Touch Devices
CSS for Touch Devices
 
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
 
Win7 Multi Touch
Win7 Multi TouchWin7 Multi Touch
Win7 Multi Touch
 
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
 
Understanding the Touch Interface [IndicThreads Mobile Application Developmen...
Understanding the Touch Interface [IndicThreads Mobile Application Developmen...Understanding the Touch Interface [IndicThreads Mobile Application Developmen...
Understanding the Touch Interface [IndicThreads Mobile Application Developmen...
 

Más de Peter-Paul Koch

Rethinking the mobile web
Rethinking the mobile webRethinking the mobile web
Rethinking the mobile webPeter-Paul Koch
 
The mobile browser world
The mobile browser worldThe mobile browser world
The mobile browser worldPeter-Paul Koch
 
The future of the mobile web
The future of the mobile webThe future of the mobile web
The future of the mobile webPeter-Paul Koch
 
The mobile browser world
The mobile browser worldThe mobile browser world
The mobile browser worldPeter-Paul Koch
 
The Mobile Web - Fronteers 2009
The Mobile Web - Fronteers 2009The Mobile Web - Fronteers 2009
The Mobile Web - Fronteers 2009Peter-Paul Koch
 
State of the Mobile Browsers
State of the Mobile BrowsersState of the Mobile Browsers
State of the Mobile BrowsersPeter-Paul Koch
 
The Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The BrowsersThe Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The BrowsersPeter-Paul Koch
 
An Event Apart Boston: Principles of Unobtrusive JavaScript
An Event Apart Boston: Principles of Unobtrusive JavaScriptAn Event Apart Boston: Principles of Unobtrusive JavaScript
An Event Apart Boston: Principles of Unobtrusive JavaScriptPeter-Paul Koch
 
Google presentation: The Open Web goes mobile
Google presentation: The Open Web goes mobileGoogle presentation: The Open Web goes mobile
Google presentation: The Open Web goes mobilePeter-Paul Koch
 
Yahoo presentation: JavaScript Events
Yahoo presentation: JavaScript EventsYahoo presentation: JavaScript Events
Yahoo presentation: JavaScript EventsPeter-Paul Koch
 

Más de Peter-Paul Koch (13)

Rethinking the mobile web
Rethinking the mobile webRethinking the mobile web
Rethinking the mobile web
 
The mobile browser world
The mobile browser worldThe mobile browser world
The mobile browser world
 
The future of the mobile web
The future of the mobile webThe future of the mobile web
The future of the mobile web
 
The mobile browser world
The mobile browser worldThe mobile browser world
The mobile browser world
 
JSON over SMS
JSON over SMSJSON over SMS
JSON over SMS
 
Samsung
SamsungSamsung
Samsung
 
The Mobile Web - Fronteers 2009
The Mobile Web - Fronteers 2009The Mobile Web - Fronteers 2009
The Mobile Web - Fronteers 2009
 
State of the Mobile Browsers
State of the Mobile BrowsersState of the Mobile Browsers
State of the Mobile Browsers
 
Vodafone Widget Camp
Vodafone Widget CampVodafone Widget Camp
Vodafone Widget Camp
 
The Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The BrowsersThe Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The Browsers
 
An Event Apart Boston: Principles of Unobtrusive JavaScript
An Event Apart Boston: Principles of Unobtrusive JavaScriptAn Event Apart Boston: Principles of Unobtrusive JavaScript
An Event Apart Boston: Principles of Unobtrusive JavaScript
 
Google presentation: The Open Web goes mobile
Google presentation: The Open Web goes mobileGoogle presentation: The Open Web goes mobile
Google presentation: The Open Web goes mobile
 
Yahoo presentation: JavaScript Events
Yahoo presentation: JavaScript EventsYahoo presentation: JavaScript Events
Yahoo presentation: JavaScript Events
 

Último

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 

Último (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 

Mobile Browser Events - Supporting Touch, Mouse and Keyboard

  • 1. Hell is other browsers - Sartre The touch events Peter-Paul Koch (ppk) http://quirksmode.org http://twitter.com/ppk WebExpo, 24 September 2010
  • 2. The desktop web Boring! - Only five browsers - with only one viewport each - that support nearly everything - Even IE? Yes, even IE.
  • 3.
  • 4. The Mobile Web Exciting! - Fifteen browsers and counting - ranging from great to lousy - Interesting new bugs - About five times as many users as the desktop web (eventually) - New interaction modes
  • 5. The Mobile Web Exciting! - Fifteen browsers and counting - ranging from great to lousy - Interesting new bugs - About five times as many users as the desktop web (eventually) - New interaction modes
  • 6. Mobile browsers - Android WebKit - NetFront - Opera Mobile - Bolt - Dolfin (bada) - UCWeb - Safari - Obigo - MicroB - Fennec - BlackBerry WebKit - Opera Mini - Symbian WebKit - IE Mobile - Palm WebKit You may groan now.
  • 7. Mobile browsers - Android WebKit - NetFront - Opera Mobile - Bolt - Dolfin (bada) - UCWeb - Safari - Obigo - MicroB - Fennec - BlackBerry WebKit - Opera Mini - Symbian WebKit - IE Mobile - Palm WebKit These are all WebKit-based.
  • 8. WebKit Mobile There is no WebKit on Mobile. There's iPhone Safari (3 and 4), and Android (1.6 and 2.1 and 2.2) and Symbian WebKit (1 and 2) and Blackberry WebKit and Palm WebKit and Dolfin for bada These WebKits are all different.
  • 9. There is no WebKit on Mobile. http://quirksmode.org/webkit.html
  • 10. Mobile web dev Focus on (in roughly this order) - iPhone - Android - BlackBerry (WebKit and old) - Symbian WebKit - Opera Mini - Opera Mobile - Dolfin (bada)
  • 11. Mobile web dev Focus on (in roughly this order) - iPhone - Android - BlackBerry (WebKit and old) - Symbian WebKit - Opera Mini - Opera Mobile - Dolfin (bada)
  • 12. Opera Mobile and Mini Opera Mobile is a normal browser. Request HTML, CSS, and JavaScript, interpret and execute them. Opera Mini, though, sends your request to a special server, which requests the HTML, CSS, and JS then interprets it and sends back basically a bitmap
  • 13. Opera Mini Opera Mini advantages: - Little memory necessary, works on old phones, too. - Less network traffic: you receive a highly compressed bitmap
  • 14. Opera Mini Opera Mini disadvantage: - No client-side interactivity. If a click event fires, Opera Mini goes back to the server to ask for instructions Tradeoff: lose client-side interactivity, but spend less money on devices and network connections.
  • 15. Mobile web dev Focus on (in roughly this order) - iPhone - Android - BlackBerry (WebKit and old) - Symbian WebKit - Opera Mini - Opera Mobile - Dolfin (bada)
  • 16. Mobile web dev Get real devices to test on. - iPhone or Android - Nokia S60 - BlackBerry (older) - Windows Mobile (useful secondary test platform) Yes, that's expensive. It's also necessary.
  • 17. Mobile web dev Get real devices to test on. - Unlocked! You should test with multiple networks - or with wifi
  • 18. Mobile web dev Use testing services: http://www.deviceanywhere.com/ http://perfectomobile.com/ Or use an emulator. Most mobile phone vendors offer one. Drawback: you can't hold them in your hand, and that's crucial for mobile.
  • 19. The Mobile Web Exciting! - Fifteen browsers and counting - ranging from great to lousy - Interesting new bugs - About five times as many users as the desktop web (eventually) - New interaction modes
  • 20. Before we start please open the following link on your phone: http://quirksmode.org/touchevents It gives links to the test files. The touch tests only work on iPhone, Android, bada, and BlackBerry Torch.
  • 21. Mouse
  • 24. Keyboard users need different Mouse interaction than mouse users need different interactions than touch users. Your script accomodates all three modes, right? It's all a question of events.
  • 28. It's not an either-or proposition.
  • 29. It's not an either-or proposition. The Nokia E71 has a four-way navigation. Works like the arrow keys (including keycodes). But...
  • 30. It's not an either-or proposition. But... the “arrow keys” steer a mouse cursor. Key events and mouse events
  • 31. Today we'll concentrate on the touch events, though.
  • 32. http://quirksmode.org/touchevents Open the first dropdown example. Task: Click on option 3.2 This is with traditional mouseover and mouseout; no touch-specific code. Works (a bit oddly, but works).
  • 33. In theory a touchscreen device should fire only the touch events, and not the mouse events. A touchscreen device doesn't have a mouse, after all. However, too many websites depend on the mouse events, so touch browser vendors are forced to support them, too.
  • 34. Touch !== mouse - Area - Pressure - Temperature - more than one touch
  • 35. http://quirksmode.org/touchevents Now open the second dropdown example. Task: Click on option 3.2 Doesn't work.
  • 36. Not an entirely fair comparison. Touchstart and touchend are not the equivalents of mouseover and mouseout. In fact, true hovering is impossible on touchscreens. There is no way of saying “I might be interested in this element but I'm not sure yet.”
  • 37. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - All All iPhone, Android, bada, BlackBerry
  • 38. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 39. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 40. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 41. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 42. When you touch the screen of a touchscreen, both touch and mouse events fire. But the mouse events are a bit special. They all fire at the same time. http://quirksmode.org/touchevents You can test the events for yourself at the touch action test page.
  • 44. Once started, the touch events keep firing regardless of where your finger is. element.ontouchmove = function () { // do stuff } This event handler continues firing even if your finger leaves the element. We need touchenter and touchleave events for when finger enters or leaves element.
  • 45. touchstart If a DOM change occurs mouseover onmouseover or mousemove onmousemove, the rest mousedown of the events is cancelled. mouseup (iPhone and Symbian) click :hover styles applied
  • 46. When the user touches another element mouseout :hover styles removed
  • 47. http://quirksmode.org/touchevents Try the Event Delegation page. Touch the bordered div. document.onclick = function () { // change divs } You click on a div, not on the document. Still, the event bubbles up. Except on the iPhone.
  • 48. The iPhone does not register a click event if the element you click on doesn't have a click event handler. document.onclick = function () { // change divs } div.onclick = function () {} Now the div itself has a click event handler, and event delegation works fine.
  • 49. http://quirksmode.org/touchevents Now open the first drag-and-drop example. Should work fine; both on touch devices and with a mouse. This is very simple.
  • 50. Mouse and touch events: element.ontouchstart = function (e) { element.ontouchmove = function (e) {etc} element.ontouchend = function (e) {etc} } element.onmousedown = function (e) { document.onmousemove = function (e) {etc} document.onmouseup = function (e) {etc} }
  • 51. Mouse and touch events: element.ontouchstart = function (e) { element.ontouchmove = function (e) {etc} element.ontouchend = function (e) {etc} element.onmousedown = null; } element.onmousedown = function (e) { document.onmousemove = function (e) {etc} document.onmouseup = function (e) {etc} } But how do you know whether to use the mouse or the touch events?
  • 52. http://quirksmode.org/touchevents Now open the second drag-and-drop example. iPhone only. Try dragging two or all three layers simultaneously. (A bit stilted, but you get the point.)
  • 53. This is impossible on a desktop computer. Two mice? Useful for games, maybe (especially on the iPad). Does not work on other browsers: they don't (yet) support true multitouch.
  • 54. http://quirksmode.org/touchevents Now open the scrolling layer example. Works fine – on mobile. But how do we port this to the other interaction modes? - keys: use arrow keys - mouse: ???
  • 55. Interaction modes - mouse - keyboard - touch - and a fourth....
  • 56. Interaction modes - mouse - keyboard - touch - trackball Generally fires a mousemove event
  • 57. Thank you! Questions? http://quirksmode.org http://twitter.com/ppk I'll post these slides on my site.