keystroke method

String keystroke()

Implementation

String keystroke() {
  final sb = StringBuffer();

  if (KeyMod.contains(mod, KeyMod.ctrl) &&
      code != keyLeftCtrl &&
      code != keyRightCtrl) {
    sb.write('ctrl+');
  }
  if (KeyMod.contains(mod, KeyMod.alt) &&
      code != keyLeftAlt &&
      code != keyRightAlt) {
    sb.write('alt+');
  }
  if (KeyMod.contains(mod, KeyMod.shift) &&
      code != keyLeftShift &&
      code != keyRightShift) {
    sb.write('shift+');
  }
  if (KeyMod.contains(mod, KeyMod.meta) &&
      code != keyLeftMeta &&
      code != keyRightMeta) {
    sb.write('meta+');
  }
  if (KeyMod.contains(mod, KeyMod.hyper) &&
      code != keyLeftHyper &&
      code != keyRightHyper) {
    sb.write('hyper+');
  }
  if (KeyMod.contains(mod, KeyMod.superKey) &&
      code != keyLeftSuper &&
      code != keyRightSuper) {
    sb.write('super+');
  }

  final name = _keyTypeString[code];
  if (name != null) {
    sb.write(name);
    return sb.toString();
  }

  var c = code;
  if (baseCode != 0) c = baseCode;

  switch (c) {
    case keySpace:
      sb.write('space');
    case keyExtended:
      sb.write(text);
    default:
      sb.write(String.fromCharCode(c));
  }
  return sb.toString();
}