Success Criterion 2.1.4 - Level A
Character Key Shortcuts
Ensure that shortcuts cannot be accidentally activated when using assistive technologies. Many assistive technologies mimic keystrokes to perform actions. This can result in unwanted shortcuts being activated. Make it possible to change or disable shortcuts.
Impact
When your app uses the same shortcuts as assistive technologies, unwanted actions could be activated.
It is nice for users if they can customize the key combinations for shortcuts.
Check
“Does the app use single keys for shortcuts?“
This can be tested using keyboard access.
Solution
Use multiple keys for shortcuts
On Android, you can use the dispatchKeyEvent
and onKeyUp
methods to activate shortcuts. Both methods give you a reference to a KeyEvent
object. Use the isShiftPressed
or isCtrlPressed
method to make sure that shortcuts are not activated by accident.
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
return when (keyCode) {
KeyEvent.KEYCODE_F -> {
if (event.isCtrlPressed) {
find()
true
}
}
else -> super.onKeyUp(keyCode, event)
}
}
private fun find() {
// Logic
}