I've setup interact.js draggable as -
interact('.draggable')
.draggable({
onstart: (event: Interact.InteractEvent) => onstartRef.current(event),
onmove: (event: Interact.InteractEvent) => onmoveRef.current(event),
onend: (event: Interact.InteractEvent) => onendRef.current(event)
})
I was trying to add support for a11y with keyboard drag with interact.js but could not find anything in documentation for it. How to bind "dragStart", "dragMove" and "dragEnd" events with keyboard events.
I could find a github issue but is there more information - https://github.com/taye/interact.js/issues/275.
I'm starting with listening to keyboard arrow-left, right, up, down, and willing to start "onStart", "onEnd" and "onMove".
switch (event.key) {
case 'ArrowLeft':
It’s quite likely that the dragging is not essential to your application, and that other interactions, like context menus, can achieve the same goal.
Don’t try to force it and replicate the exact same interaction, just with keyboard. Steering an element across the screen by means of arrow keys might be playful at first, but is cumbersome when trying to get a job done.
Plus, it still is inaccessible to users with vision impairments.
The WCAG 2.2 explicitly demand a single pointer interaction
The currently sole sufficient technique to satisfy that criterion is listing some examples:
In windows, you can drag an item onto your trash icon, or you can right click it and select “Delete”. The context menu is keyboard accessible.