W3cubDocs

/Dart 2

isCharacterKey method

bool isCharacterKey (int keyCode)

Returns true if the keyCode produces a (US keyboard) character. Note: This does not (yet) cover characters on non-US keyboards (Russian, Hebrew, etc.).

Implementation

static bool isCharacterKey(int keyCode) {
  if ((keyCode >= ZERO && keyCode <= NINE) ||
      (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) ||
      (keyCode >= A && keyCode <= Z)) {
    return true;
  }

  // Safari sends zero key code for non-latin characters.
  if (Device.isWebKit && keyCode == 0) {
    return true;
  }

  return (keyCode == SPACE ||
      keyCode == QUESTION_MARK ||
      keyCode == NUM_PLUS ||
      keyCode == NUM_MINUS ||
      keyCode == NUM_PERIOD ||
      keyCode == NUM_DIVISION ||
      keyCode == SEMICOLON ||
      keyCode == FF_SEMICOLON ||
      keyCode == DASH ||
      keyCode == EQUALS ||
      keyCode == FF_EQUALS ||
      keyCode == COMMA ||
      keyCode == PERIOD ||
      keyCode == SLASH ||
      keyCode == APOSTROPHE ||
      keyCode == SINGLE_QUOTE ||
      keyCode == OPEN_SQUARE_BRACKET ||
      keyCode == BACKSLASH ||
      keyCode == CLOSE_SQUARE_BRACKET);
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-html/KeyCode/isCharacterKey.html