diff --git a/app/features/settings/components/SettingsButton.js b/app/features/settings/components/SettingsButton.js index 6d030cc..aee13c2 100644 --- a/app/features/settings/components/SettingsButton.js +++ b/app/features/settings/components/SettingsButton.js @@ -2,6 +2,9 @@ import SettingsIcon from '@atlaskit/icon/glyph/settings'; +import * as Mousetrap from 'mousetrap'; +import 'mousetrap/plugins/global-bind/mousetrap-global-bind'; + import React, { Component } from 'react'; import { connect } from 'react-redux'; import type { Dispatch } from 'redux'; @@ -18,6 +21,11 @@ type Props = { dispatch: Dispatch<*>; }; +/** + * Shortcut keys by which the drawer will open. + */ +const drawerShortcut = [ 'command+,', 'ctrl+shift+s' ]; + /** * Setttings button for Navigation Bar. */ @@ -33,6 +41,24 @@ class SettingButton extends Component { this._onIconClick = this._onIconClick.bind(this); } + /** + * Bind shortcut when the component did mount. + * + * @returns {void} + */ + componentDidMount() { + Mousetrap.bindGlobal(drawerShortcut, this._onIconClick); + } + + /** + * Bind shortcut when the component before unmount. + * + * @returns {void} + */ + componentWillUnmount() { + Mousetrap.unbind(drawerShortcut); + } + /** * Render function of component. * diff --git a/package-lock.json b/package-lock.json index 85d5142..5718f48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8461,6 +8461,11 @@ } } }, + "mousetrap": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/mousetrap/-/mousetrap-1.6.2.tgz", + "integrity": "sha512-jDjhi7wlHwdO6q6DS7YRmSHcuI+RVxadBkLt3KHrhd3C2b+w5pKefg3oj5beTcHZyVFA9Aksf+yEE1y5jxUjVA==" + }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", diff --git a/package.json b/package.json index c05a5b0..fad0d00 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "history": "4.7.2", "jitsi-meet-electron-utils": "github:jitsi/jitsi-meet-electron-utils#1972c3bf0884ace68eb496894dabae593d6dbf49", "js-md5": "0.7.3", + "mousetrap": "1.6.2", "react": "16.3.2", "react-dom": "16.3.2", "react-redux": "5.0.7",