@@ -16,10 +16,10 @@ limitations under the License.
1616
1717import React , { createRef } from "react" ;
1818import PropTypes from 'prop-types' ;
19- import { Key } from '../../Keyboard' ;
2019import Timer from '../../utils/Timer' ;
2120import AutoHideScrollbar from "./AutoHideScrollbar" ;
2221import { replaceableComponent } from "../../utils/replaceableComponent" ;
22+ import { getKeyBindingsManager , RoomAction } from "../../KeyBindingsManager" ;
2323
2424const DEBUG_SCROLL = false ;
2525
@@ -535,29 +535,19 @@ export default class ScrollPanel extends React.Component {
535535 * @param {object } ev the keyboard event
536536 */
537537 handleScrollKey = ev => {
538- switch ( ev . key ) {
539- case Key . PAGE_UP :
540- if ( ! ev . ctrlKey && ! ev . shiftKey && ! ev . altKey && ! ev . metaKey ) {
541- this . scrollRelative ( - 1 ) ;
542- }
538+ const roomAction = getKeyBindingsManager ( ) . getRoomAction ( ev ) ;
539+ switch ( roomAction ) {
540+ case RoomAction . ScrollUp :
541+ this . scrollRelative ( - 1 ) ;
543542 break ;
544-
545- case Key . PAGE_DOWN :
546- if ( ! ev . ctrlKey && ! ev . shiftKey && ! ev . altKey && ! ev . metaKey ) {
547- this . scrollRelative ( 1 ) ;
548- }
543+ case RoomAction . RoomScrollDown :
544+ this . scrollRelative ( 1 ) ;
549545 break ;
550-
551- case Key . HOME :
552- if ( ev . ctrlKey && ! ev . shiftKey && ! ev . altKey && ! ev . metaKey ) {
553- this . scrollToTop ( ) ;
554- }
546+ case RoomAction . JumpToFirstMessage :
547+ this . scrollToTop ( ) ;
555548 break ;
556-
557- case Key . END :
558- if ( ev . ctrlKey && ! ev . shiftKey && ! ev . altKey && ! ev . metaKey ) {
559- this . scrollToBottom ( ) ;
560- }
549+ case RoomAction . JumpToLatestMessage :
550+ this . scrollToBottom ( ) ;
561551 break ;
562552 }
563553 } ;
0 commit comments