which property

  1. @deprecated
int? which

For key or mouse events, this property indicates the specific key

  • or button that was pressed.
  • For key events, it normalizes event.keyCode and event.charCode.
  • It is recommended to watch event.which for keyboard key input.
  • For mouse events, it normalizes button presses (mousedown and mouseupevents),
  • reporting 1 for left button, 2 for middle, and 3 for right.
  • Use event.which instead of event.button.

Implementation

@deprecated
int? get which {
  if (_which == null) {
    final event = originalEvent;
    if (event is KeyboardEvent) { //including KeyEvent
  //jQuery: Add which for key events
      _which = event.charCode;

    } else if (event is MouseEvent) {
  // jQuery: Add which for click: 1 === left; 2 === middle; 3 === right
  // jQuery: Note: button is not normalized, so don't use it
      final buttons = event.buttons;
      _which =
          buttons == null ? event.button + 1: //Safari: no buttons
          (buttons & 1) != 0 ? 1:
          (buttons & 2) != 0 ? 3: (buttons & 4) != 0 ? 2 : 0;
    } else if (event is QueryEvent) {
      _which = event.which;
    }
  }
  return _which;
}