UNPKG

1.15 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @format
8 *
9 * @emails oncall+draft_js
10 */
11'use strict';
12
13var UserAgent = require("fbjs/lib/UserAgent");
14
15var isSoftNewlineEvent = require("./isSoftNewlineEvent");
16
17var isOSX = UserAgent.isPlatform('Mac OS X');
18var KeyBindingUtil = {
19 /**
20 * Check whether the ctrlKey modifier is *not* being used in conjunction with
21 * the altKey modifier. If they are combined, the result is an `altGraph`
22 * key modifier, which should not be handled by this set of key bindings.
23 */
24 isCtrlKeyCommand: function isCtrlKeyCommand(e) {
25 return !!e.ctrlKey && !e.altKey;
26 },
27 isOptionKeyCommand: function isOptionKeyCommand(e) {
28 return isOSX && e.altKey;
29 },
30 usesMacOSHeuristics: function usesMacOSHeuristics() {
31 return isOSX;
32 },
33 hasCommandModifier: function hasCommandModifier(e) {
34 return isOSX ? !!e.metaKey && !e.altKey : KeyBindingUtil.isCtrlKeyCommand(e);
35 },
36 isSoftNewlineEvent: isSoftNewlineEvent
37};
38module.exports = KeyBindingUtil;
\No newline at end of file