Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 98e7730

Browse files
williambomanfacebook-github-bot
authored andcommitted
KeyBindingUtil: add usesMacOSHeuristics method (#869)
Summary: **Summary** Add a public method, `usesMacOSHeuristics`, to the `KeyBindingUtil` module. This makes it possible to determine how draft-js will interpret certain keyboard events and thus alter the UI accordingly, e.g.; <img width="499" alt="screenshot 2016-12-13 at 17 58 33" src="https://cloud.githubusercontent.com/assets/6705160/21150013/dee64566-c15d-11e6-9639-75a39d21d079.png"> I currently achieve this by doing (🙈); ```js const COMMAND_MODIFIER_CHAR = (navigator && navigator.userAgent.indexOf('Mac') >= 0) ? '\u2318' // Mac command key character : 'Ctrl' ``` Pull Request resolved: #869 Differential Revision: D9734962 fbshipit-source-id: ed3f3d0a87df51c708fd666fe85bc6acba1ecfee
1 parent c6ff39d commit 98e7730

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/APIReference-KeyBindingUtil.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ isOptionKeyCommand: function(
2828
): boolean
2929
```
3030

31+
### usesMacOSHeuristics
32+
33+
```
34+
usesMacOSHeuristics: function(): boolean
35+
```
36+
37+
Check whether heuristics that only apply to macOS are used internally, for
38+
example when determining the key combination used as command modifier.
39+
3140
### hasCommandModifier
3241

3342
```

src/component/utils/KeyBindingUtil.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const KeyBindingUtil = {
3131
return isOSX && e.altKey;
3232
},
3333

34+
usesMacOSHeuristics: function(): boolean {
35+
return isOSX;
36+
},
37+
3438
hasCommandModifier: function(e: SyntheticKeyboardEvent<>): boolean {
3539
return isOSX
3640
? !!e.metaKey && !e.altKey

0 commit comments

Comments
 (0)