Created
October 25, 2019 12:39
-
-
Save andreasvirkus/dcaaae7db870a44532c42e58cf60513f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onKeydown(e) { | |
const { toggleSidebar, next, previous } = this.props; | |
const keyMapping = new Map([ | |
[ 83, toggleSidebar ], // user presses the s button | |
[ 37, next ], // user presses the right arrow | |
[ 39, previous ] // user presses the left arrow | |
]); | |
if (keyMapping.has(e.which)) { | |
e.preventDefault(); | |
keyMapping.get(e.which)(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment