File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -718,9 +718,38 @@ const saveReadingSettings = () => {
718718 }
719719}
720720
721+ const SCROLL_STEP = 300
722+
721723// 键盘快捷键
722724const handleKeydown = (event ) => {
725+ const target = event .target
726+ const isInputFocused = target instanceof HTMLElement && [' INPUT' , ' TEXTAREA' , ' SELECT' ].includes (target .tagName )
727+
723728 switch (event .key ) {
729+ case ' ArrowUp' :
730+ if (isInputFocused) return
731+ event .preventDefault ()
732+ if (contentRef .value ) {
733+ contentRef .value .scrollBy ({ top: - SCROLL_STEP , behavior: ' smooth' })
734+ }
735+ break
736+ case ' ArrowDown' :
737+ if (isInputFocused) return
738+ event .preventDefault ()
739+ if (contentRef .value ) {
740+ contentRef .value .scrollBy ({ top: SCROLL_STEP , behavior: ' smooth' })
741+ }
742+ break
743+ case ' ArrowLeft' :
744+ if (isInputFocused) return
745+ event .preventDefault ()
746+ handlePrevChapter ()
747+ break
748+ case ' ArrowRight' :
749+ if (isInputFocused) return
750+ event .preventDefault ()
751+ handleNextChapter ()
752+ break
724753 case ' Escape' :
725754 event .preventDefault ()
726755 if (showChapterPanel .value ) {
You can’t perform that action at this time.
0 commit comments