Skip to content

Event API: add key modifiers to Press events#15611

Merged
trueadm merged 1 commit intofacebook:masterfrom
trueadm:add-altKey-modifier
May 10, 2019
Merged

Event API: add key modifiers to Press events#15611
trueadm merged 1 commit intofacebook:masterfrom
trueadm:add-altKey-modifier

Conversation

@trueadm
Copy link
Contributor

@trueadm trueadm commented May 10, 2019

This PR adds keyboard modifier booleans (altKey, altKey, metaKey and shiftKey) to Press events, so user-land gets access to this information. Furthermore, I also added x and y to Press events too (alias for clientX and clientY).

@sizebot
Copy link

sizebot commented May 10, 2019

Details of bundled changes.

Comparing: 3d8b836...4de3f4e

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events.production.min.js 0.0% -0.2% 682 B 682 B 431 B 430 B UMD_PROD
react-events.production.min.js 0.0% -0.3% 512 B 512 B 354 B 353 B NODE_PROD
react-events-press.development.js +2.0% +2.2% 20.06 KB 20.46 KB 4.53 KB 4.63 KB UMD_DEV
react-events-press.production.min.js 🔺+1.7% 🔺+2.5% 7.48 KB 7.6 KB 2.58 KB 2.65 KB UMD_PROD
react-events-press.development.js +2.0% +2.3% 19.87 KB 20.27 KB 4.47 KB 4.57 KB NODE_DEV
react-events-press.production.min.js 🔺+1.7% 🔺+2.9% 7.3 KB 7.42 KB 2.52 KB 2.59 KB NODE_PROD
ReactEventsPress-dev.js +2.3% +2.1% 20.7 KB 21.17 KB 4.64 KB 4.73 KB FB_WWW_DEV
ReactEventsPress-prod.js 🔺+2.2% 🔺+2.6% 17.73 KB 18.13 KB 3.59 KB 3.68 KB FB_WWW_PROD
react-events-hover.development.js 0.0% -0.0% 8.49 KB 8.49 KB 2.07 KB 2.07 KB UMD_DEV
react-events-hover.production.min.js 0.0% -0.1% 3.64 KB 3.64 KB 1.34 KB 1.34 KB UMD_PROD
react-events-hover.production.min.js 0.0% -0.1% 3.47 KB 3.47 KB 1.29 KB 1.29 KB NODE_PROD
react-events-focus.development.js 0.0% -0.1% 6.06 KB 6.06 KB 1.58 KB 1.58 KB UMD_DEV
react-events-focus.production.min.js 0.0% -0.1% 2.71 KB 2.71 KB 1.06 KB 1.06 KB UMD_PROD
react-events-focus.production.min.js 0.0% -0.1% 2.52 KB 2.52 KB 996 B 995 B NODE_PROD
react-events-focus-scope.production.min.js 0.0% -0.1% 1.96 KB 1.96 KB 978 B 977 B UMD_PROD
react-events-focus-scope.production.min.js 0.0% -0.1% 1.77 KB 1.77 KB 892 B 891 B NODE_PROD
react-events-swipe.production.min.js 0.0% -0.1% 2.66 KB 2.66 KB 1.24 KB 1.24 KB UMD_PROD
react-events-swipe.production.min.js 0.0% -0.1% 3.3 KB 3.3 KB 1.52 KB 1.52 KB NODE_PROD
react-events-drag.development.js 0.0% -0.1% 5.72 KB 5.72 KB 1.62 KB 1.62 KB UMD_DEV
react-events-drag.production.min.js 0.0% -0.1% 2.52 KB 2.52 KB 1.15 KB 1.15 KB UMD_PROD

Generated by 🚫 dangerJS

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@trueadm trueadm merged commit 91a044e into facebook:master May 10, 2019
@trueadm trueadm deleted the add-altKey-modifier branch May 10, 2019 12:32

if (event) {
const nativeEvent = (event.nativeEvent: any);
({altKey, ctrlKey, metaKey, shiftKey} = nativeEvent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the extra () here? prettier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need it, otherwise it doesn't assign to those bindings. Prettier will add them in anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants