Skip to content

Commit

Permalink
Binding arrow key for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-dev committed Oct 20, 2024
1 parent c60e4e1 commit f09618c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion violet/lib/pages/viewer/viewer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,30 @@ class _ViewerPageState extends State<ViewerPage> {
);
}

final pageKeyListener = KeyboardListener(
focusNode: FocusNode(),
onKeyEvent: (KeyEvent event) {
if (event is KeyDownEvent) {
switch (event.logicalKey) {
case LogicalKeyboardKey.arrowDown:
case LogicalKeyboardKey.arrowLeft:
c.prev();
break;

case LogicalKeyboardKey.arrowUp:
case LogicalKeyboardKey.arrowRight:
c.next();
break;
}
}
},
child: body,
);

return PopScope(
canPop: true,
onPopInvoked: _handlePopInvoked,
child: body,
child: pageKeyListener,
);
}

Expand Down

0 comments on commit f09618c

Please sign in to comment.