5 Keyboard shortcuts
(ns oiiku.admin.frontend.docs.shortcuts
(:require [oiiku.qa :as qa]))Keyboard shortcuts are implemented with a concern towards separation of issues. All implementation details reside in oiiku.admin.frontend.shortcuts.
5.1 Requirements
- Press a key and have one or more actions take place
- The key should be using the input source, not the physical key, so that using DVORAK or QWERTY or QWERTZ shouldn’t introduce suprises
- Support for modifier keys (ctrl, alt, meta, shift)
- Change the keys depending on where you are in the app
- Have help text for the shortcuts
- Show the available shortcuts via a widget
- Have the same keybinding for different modals with different actions attached to it.
- Disable shortcuts depending on the state in the app
- This can be things like a modal window being active, disabling shortcuts for the datagrid while you are active inside the modal window
- We can also have situations where a modal window opens up another modal window
- Disabled shortcuts should be shown in the widget, but marked visually as currently unavailable
5.2 Constraints
- We can only have one set of keys active at all times
- Input source, instead of physical key
- We need to know where we are in the hierarchy (modal window on top of a modal window)
- We need to register handlers on the document and to specific event types
- This needs to be done only once
- This needs to be cleaned up when it’s no longer necessary (e.g. switching module)
5.3 Current problems
Due to going for .-key instead of .-code, we avoid the problem of using the physical mapping, when users want to use the keyboard layout mapping instead. This introduces a new problem, where the Alt modifier key changes the character that they keypress produces. As a result, Alt+K gives ˚ and Ctrl+Alt+Meta+H gives ˙, etc. Our current solution is to avoid using keyboard shortcuts that would require such a keyboard combination.
(qa/display "app" "shortcuts/scene1")source: bases/admin-web/src/oiiku/admin/frontend/docs/shortcuts.clj