Created
January 26, 2023 14:37
-
-
Save jonathantneal/cfc2849fc85fa0ebdc9494c21b34dfba to your computer and use it in GitHub Desktop.
modifierKey for KeyboardEvent — 164 bytes / 140 bytes gzipped
This file contains 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
// Define the KeyboardEvent.modifierKey getter as the platform modifier key | |
KeyboardEvent.prototype.__defineGetter__( | |
'modifierKey', | |
KeyboardEvent.prototype.__lookupGetter__( | |
// The modifier key is meta for Apple devices, otherwise control | |
/^(MacIntel|iPhone)$/.test(navigator.platform) ? 'metaKey' : 'ctrlKey' | |
) | |
) |
This file contains 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
KeyboardEvent.prototype.__defineGetter__("modifierKey",KeyboardEvent.prototype.__lookupGetter__(/^(MacIntel|iPhone)$/.test(navigator.platform)?"metaKey":"ctrlKey")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment