keystrokeToDisplayString function

String keystrokeToDisplayString(
  1. ParsedKeystroke ks, {
  2. String platform = 'linux',
})

Convert a ParsedKeystroke to a platform-appropriate display string.

Implementation

String keystrokeToDisplayString(
  ParsedKeystroke ks, {
  String platform = 'linux',
}) {
  final parts = <String>[];
  if (ks.ctrl) parts.add('ctrl');
  if (ks.alt || ks.meta) {
    parts.add(platform == 'macos' ? 'opt' : 'alt');
  }
  if (ks.shift) parts.add('shift');
  if (ks.superKey) {
    parts.add(platform == 'macos' ? 'cmd' : 'super');
  }
  parts.add(_keyToDisplayName(ks.key));
  return parts.join('+');
}