* `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)
| 16569 | */ |
| 16570 | |
| 16571 | function 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 | |
| 16596 | module.exports = getEventCharCode; |
| 16597 | },{}],122:[function(_dereq_,module,exports){ |
no outgoing calls
no test coverage detected
searching dependent graphs…