File tree 2 files changed +41
-0
lines changed
input-device-capabilities
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ Input Device Capabilities Sample
2
+ ===
3
+ See https://googlechrome.github.io/samples/input-device-capabilities/index.html for a live demo.
4
+
5
+ Learn more at https://www.chromestatus.com/feature/5681847971348480
Original file line number Diff line number Diff line change
1
+ ---
2
+ feature_name: Input Device Capabilities
3
+ chrome_version: 47
4
+ feature_id: 5681847971348480
5
+ ---
6
+
7
+ < h3 > Background</ h3 >
8
+ < p >
9
+ The Input Device Capabilities API provides information about the capabilities of the physical
10
+ device responsible for generating an event.
11
+ </ p >
12
+ < p >
13
+ This sample illustrates using < code > UIEvent.sourceCapabilities</ code > (via a < code > click</ code >
14
+ < code > UIEvent</ code > ) to obtain the capabilities of the device that triggered the click, and
15
+ then checks the < code > firesTouchEvents</ code > property to determine whether that device can also
16
+ create a < a href ="http://www.w3.org/TR/touch-events/#touchevent-interface "> < code > TouchEvent</ code > </ a > .
17
+ </ p >
18
+ < p >
19
+ The < a href ="http://www.html5rocks.com/en/mobile/touchandmouse/#toc-mostimp "> < em > Touch and Mouse</ em > </ a >
20
+ article provides some background on why that knowledge is important for developers.
21
+ </ p >
22
+
23
+ {% capture initial_output_content %}
24
+ < button id ="press-me "> Press Me!</ button >
25
+ {% endcapture %}
26
+ {% include output_helper.html initial_output_content=initial_output_content %}
27
+
28
+ {% capture js %}
29
+ document.querySelector('#press-me').addEventListener('click', function(event) {
30
+ var status = 'The device that triggered this click event ' +
31
+ (event.sourceCapabilities.firesTouchEvents ? 'does' : 'does not') +
32
+ ' fire touch events.';
33
+ ChromeSamples.setStatus(status);
34
+ });
35
+ {% endcapture %}
36
+ {% include js_snippet.html js=js %}
You can’t perform that action at this time.
0 commit comments