diff --git a/lib/pages/viewer/horizontal_viewer_page.dart b/lib/pages/viewer/horizontal_viewer_page.dart index e63d474d2..04cdb452d 100644 --- a/lib/pages/viewer/horizontal_viewer_page.dart +++ b/lib/pages/viewer/horizontal_viewer_page.dart @@ -26,6 +26,7 @@ class HorizontalViewerPage extends StatefulWidget { class _HorizontalViewerPageState extends State { late final ViewerController c; + Duration? lastKeyPressedTimeStamp; @override void initState() { @@ -76,6 +77,27 @@ class _HorizontalViewerPageState extends State { ), ), ), + KeyboardListener( + focusNode: FocusNode(), + onKeyEvent: (event) { + if(lastKeyPressedTimeStamp != null){ + print('${event.timeStamp.inSeconds}'); + print('${lastKeyPressedTimeStamp!.inSeconds}'); + // print(event.timeStamp.inSeconds - lastKeyPressedTimeStamp!.inSeconds); + if((event.timeStamp.inMilliseconds - lastKeyPressedTimeStamp!.inMilliseconds) < 250) return; + } + lastKeyPressedTimeStamp = event.timeStamp; + if(event.physicalKey.debugName == 'Arrow Left'){ + c.leftButton(); + // print(event.timeStamp.toString()); + } + if(event.physicalKey.debugName == 'Arrow Right'){ + c.rightButton(); + // print(event.timeStamp.toString()); + } + }, + child: Container(), + ), Align( alignment: Alignment.center, child: Container( diff --git a/lib/pages/viewer/vertical_viewer_page.dart b/lib/pages/viewer/vertical_viewer_page.dart index 5da4c75cb..60b940193 100644 --- a/lib/pages/viewer/vertical_viewer_page.dart +++ b/lib/pages/viewer/vertical_viewer_page.dart @@ -32,6 +32,7 @@ class VerticalViewerPage extends StatefulWidget { class _VerticalViewerPageState extends State with SingleTickerProviderStateMixin { late final ViewerController c; + Duration? lastKeyPressedTimeStamp; /// this is used for interactive viewer widget /// double-tap a specific location to zoom in on that location. @@ -185,9 +186,34 @@ class _VerticalViewerPageState extends State color: null, width: width, height: height, - child: CustomDoubleTapGestureDectector( - onTap: _touchEvent, - onDoubleTap: _doubleTapEvent, + child: Column( + children:[ + CustomDoubleTapGestureDectector( + onTap: _touchEvent, + onDoubleTap: _doubleTapEvent, + ), + KeyboardListener( + focusNode: FocusNode(), + onKeyEvent: (event) { + if(lastKeyPressedTimeStamp != null){ + print('${event.timeStamp.inSeconds}'); + print('${lastKeyPressedTimeStamp!.inSeconds}'); + // print(event.timeStamp.inSeconds - lastKeyPressedTimeStamp!.inSeconds); + if((event.timeStamp.inMilliseconds - lastKeyPressedTimeStamp!.inMilliseconds) < 250) return; + } + lastKeyPressedTimeStamp = event.timeStamp; + if(event.physicalKey.debugName == 'Arrow Left'){ + c.leftButton(); + // print(event.timeStamp.toString()); + } + if(event.physicalKey.debugName == 'Arrow Right'){ + c.rightButton(); + // print(event.timeStamp.toString()); + } + }, + child: Container(), + ), + ], ), ); }