Manuel Matuzović @mmatuzo pitercss 06/2017
UX Manuel Matuzovi @mmatuzo pitercss 06/2017 Manuel Matuzovic - - PowerPoint PPT Presentation
UX Manuel Matuzovi @mmatuzo pitercss 06/2017 Manuel Matuzovic - - PowerPoint PPT Presentation
ACCESSIBLE UX Manuel Matuzovi @mmatuzo pitercss 06/2017 Manuel Matuzovic Manuel Matuzovi , , , d , , , nj, lj q, w, x Keyboard layouts A keyboard layout is any specific mechanical, visual, or functional arrangement
Manuel Matuzovic
Manuel Matuzović
č, ć, đ, dž, š, ž, nj, lj q, w, x
Keyboard layouts
“A keyboard layout is any specific mechanical, visual, or functional arrangement of the keys, legends, or key-meaning associations (respectively) of a computer, typewriter, or
- ther typographic keyboard.”
Wikipedia
QWERTY
QWERTZ
AZERTY
JCUKEN
Soooo?
event.keyCode
window.addEventListener('keydown', navigate); function navigate(e) { ... if (e.keyCode === 68) { moveLeftAndRight(1); } if (e.keyCode === 90) { shootMissile(); } }
Issues
- Different meaning of properties when handling a key event (keydown
- r keyup) versus a character event (keypress).
- The values of keys in keypress events are different between browsers.
- Inconsistent values for keys and events cross-browser
- keyCode on key events tries to be international-friendly, but isn’t
w s a d z forward back lefu right shoot
A W S D Z
QWERTY QWERTZ
QWERTY
Remember AZERTY?
UI Events: API
- Two new properties: key and code
- event.key - printable character or a descriptive string, e.g. z
- event.code - physical key, e.g. KeyY
- Reference keyboard in the specification
Reference keyboard
window.addEventListener('keydown', navigate); function navigate(e) { ... if (e.code === 'KeyD') { moveLeftAndRight(1); } if (e.code === 'KeyY') { shootMissile(); } }
event.keyCode
Browsersupport
Browsersupport
switch(e.code || e.keyCode ) { ... case 'KeyD': case 'ArrowRight': case 39: moveLeftAndRight(1); ... }
Fallback
Notes
- There is no way of checking for the current keyboard layout.
- Use the repeat property to check if the user keeps pressing a key
and the event is sent repeatedly
- Boolean properties for modifier keys (altKey, ctrlKey, metaKey,
shiftKey).
- Still a Working Drafu: There are some inconsistencies between
browsers.
https://codepen.io/matuzo/pen/PmgWRm?editors=0010
TWEETABLE TAKE-AWAY
The web is international and so are your users. Don’t assume that all users use the same input devices.
lang aturibute
<!DOCTYPE html> <html lang="en"> <head> <title>Document</title> </head> <body> </body> </html>
lang aturibute
lang aturibute: impacts
- Assistive Technology
- Translation tools and browsers
- Quote characters
- Date and Number inputs
- Search engines
- Hyphenation
TWEETABLE TAKE-AWAY
Make sure to tell the browser the correct language in use. Everyone benefits from it.
keyboard usage
Surfing the web without a mouse sucks…
…and it’s our fault!
BUT!
We can fix it!
Missing or insufficient focus styles
* {
- utline: none;
}
:focus styling
a:focus { color: #FF00FF; }
:focus styling
a:focus-ring {
- utline: 1px solid #FF00FF;
}
:focus-ring
Polyfill: https://github.com/WICG/focus-ring
form:focus-within { background:#FF00FF; }
:focus-within
Browsersupport
Tabbable/focusable elements
- Input elements, selects, textareas
- Links
- Contenteditable elements
- audio, video with controls
- …
tabindex (focusable and tabbable)
<h2 tabindex="0"> A focusable heading </h2>
<h2 tabindex="-1"> A focusable heading </h2>
tabindex (just focusable)