MCPcopy Create free account
hub / github.com/Lobos/react-ui / getEventKey

Function getEventKey

docs/lib/react.js:16670–16697  ·  view source on GitHub ↗

* @param {object} nativeEvent Native browser event. * @return {string} Normalized `key` property.

(nativeEvent)

Source from the content-addressed store, hash-verified

16668 * @return {string} Normalized `key` property.
16669 */
16670function getEventKey(nativeEvent) {
16671 if (nativeEvent.key) {
16672 // Normalize inconsistent values reported by browsers due to
16673 // implementations of a working draft specification.
16674
16675 // FireFox implements `key` but returns `MozPrintableKey` for all
16676 // printable characters (normalized to `Unidentified`), ignore it.
16677 var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
16678 if (key !== 'Unidentified') {
16679 return key;
16680 }
16681 }
16682
16683 // Browser does not implement `key`, polyfill as much of it as we can.
16684 if (nativeEvent.type === 'keypress') {
16685 var charCode = getEventCharCode(nativeEvent);
16686
16687 // The enter-key is technically both printable and non-printable and can
16688 // thus be captured by `keypress`, no other non-printable key should.
16689 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
16690 }
16691 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
16692 // While user keyboard layout determines the actual meaning of each
16693 // `keyCode` value, almost all function keys have a universal value.
16694 return translateToKey[nativeEvent.keyCode] || 'Unidentified';
16695 }
16696 return '';
16697}
16698
16699module.exports = getEventKey;
16700},{"121":121}],123:[function(_dereq_,module,exports){

Callers

nothing calls this directly

Calls 1

getEventCharCodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…