letter static method

KeyBindings letter({
  1. required String char,
  2. required void onPress(),
  3. String? hintLabel,
  4. String? hintDescription,
})

Creates letter key binding for a specific character (case-insensitive).

Implementation

static KeyBindings letter({
  required String char,
  required void Function() onPress,
  String? hintLabel,
  String? hintDescription,
}) {
  final lower = char.toLowerCase();
  final upper = char.toUpperCase();
  return KeyBindings([
    KeyBinding.char(
      (c) => c == lower || c == upper,
      (event) {
        onPress();
        return KeyActionResult.handled;
      },
      hintLabel: hintLabel ?? upper,
      hintDescription: hintDescription,
    ),
  ]);
}