diff --git a/src/pyj/read_book/shortcuts.pyj b/src/pyj/read_book/shortcuts.pyj index 6273d099e1..8042f2960e 100644 --- a/src/pyj/read_book/shortcuts.pyj +++ b/src/pyj/read_book/shortcuts.pyj @@ -90,10 +90,8 @@ def key_as_text(evt): return mods + key -def shortcuts_definition(): - ans = shortcuts_definition.ans - if not ans: - ans = shortcuts_definition.ans = { +def common_shortcuts(): # {{{ + return { 'start_of_file': desc( v"['Ctrl+ArrowUp', 'Ctrl+ArrowLeft', 'Home']", 'scroll', @@ -364,14 +362,22 @@ def shortcuts_definition(): _('Auto scroll slower'), ), - } + } # }}} - if not runtime.is_standalone_viewer: - ans['sync_book'] = desc( - v"[]", - 'ui', - _('Sync last read position/annotations'), - ) + +def shortcuts_definition(): + ans = shortcuts_definition.ans + if not ans: + ans = shortcuts_definition.ans = common_shortcuts() + + if runtime.is_standalone_viewer: + add_standalone_viewer_shortcuts(ans) + else: + ans['sync_book'] = desc( + v"[]", + 'ui', + _('Sync last read position/annotations'), + ) return ans @@ -387,9 +393,8 @@ def shortcuts_group_desc(): -def add_standalone_viewer_shortcuts(): +def add_standalone_viewer_shortcuts(sc): ismacos = 'macos' in window.navigator.userAgent - sc = shortcuts_definition() sc['toggle_inspector'] = desc( v"['Ctrl+i']", 'ui', diff --git a/src/pyj/viewer-main.pyj b/src/pyj/viewer-main.pyj index 0b76e4b711..2d74cea0e1 100644 --- a/src/pyj/viewer-main.pyj +++ b/src/pyj/viewer-main.pyj @@ -19,7 +19,6 @@ from read_book.db import new_book from read_book.footnotes import main as footnotes_main from read_book.globals import runtime, set_system_colors, ui_operations, default_color_schemes from read_book.iframe import main as iframe_main -from read_book.shortcuts import add_standalone_viewer_shortcuts from read_book.view import View from read_book.prefs.head_foot import set_time_formatter from session import local_storage, session_defaults @@ -303,7 +302,6 @@ if window is window.top: TRANSLATIONS_DATA = v'__TRANSLATIONS_DATA__' if TRANSLATIONS_DATA: install(TRANSLATIONS_DATA) - add_standalone_viewer_shortcuts() ui_operations.get_file = get_file ui_operations.get_mathjax_files = get_mathjax_files ui_operations.update_url_state = update_url_state @@ -430,4 +428,3 @@ else: footnotes_main() else: iframe_main() - add_standalone_viewer_shortcuts()