Skip to content

Keyboard and touch

keyboard=True makes each item of a sortable focusable (Tab reaches it) and lets it move without a mouse:

  • Alt+↑ / Alt+↓ move the focused item one place (← / → in a horizontal list).
  • Space picks the item up; then the arrows move it, and Space again (or Esc) puts it down.

Every move calls on_reorder with the same event as a drag, so the same handler works:

pz.sortable(items=self.tasks, item=self.task, key=str, id="tasks", keyboard=True,
on_reorder=lambda e: pz.dnd.move(self.tasks, e))

During any drag, Esc cancels it and the item flies back home.

On touch screens a swipe should scroll the list, not drag an item. delay= asks for a long press (in milliseconds) before a drag starts:

pz.sortable(..., delay=250)
pz.draggable(photo, p.id, delay=300)

A higher threshold (in pixels) also helps with shaky hands or pens.

Lists inside a pz.scrollable scroll by themselves when you drag an item near their top or bottom (left or right) edge, faster the closer you get, so you can move an item to a place that is not on screen.