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

Function getEventCharCode

docs/lib/react.js:16571–16594  ·  view source on GitHub ↗

* `charCode` represents the actual "character code" and is safe to use with * `String.fromCharCode`. As such, only keys that correspond to printable * characters produce a valid `charCode`, the only exception to this is Enter. * The Tab-key is considered non-printable and does not have a `charCod

(nativeEvent)

Source from the content-addressed store, hash-verified

16569 */
16570
16571function getEventCharCode(nativeEvent) {
16572 var charCode;
16573 var keyCode = nativeEvent.keyCode;
16574
16575 if ('charCode' in nativeEvent) {
16576 charCode = nativeEvent.charCode;
16577
16578 // FF does not set `charCode` for the Enter-key, check against `keyCode`.
16579 if (charCode === 0 && keyCode === 13) {
16580 charCode = 13;
16581 }
16582 } else {
16583 // IE8 does not implement `charCode`, but `keyCode` has the correct value.
16584 charCode = keyCode;
16585 }
16586
16587 // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
16588 // Must not discard the (non-)printable Enter-key.
16589 if (charCode >= 32 || charCode === 13) {
16590 return charCode;
16591 }
16592
16593 return 0;
16594}
16595
16596module.exports = getEventCharCode;
16597},{}],122:[function(_dereq_,module,exports){

Callers 2

react.jsFile · 0.85
getEventKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…