Minor fix in state keyCaptures

Mixing up next and previous.
Refactor keycapturing in sidepanel
Refactor key capturing once more.