"""Key geometry of the K65 PLUS (75 %, ISO-DE) in key units.""" from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True) class Key: label: str x: float y: float w: float = 1.0 h: float = 1.0 iso_enter: bool = False @property def cx(self) -> float: return self.x + self.w / 2 @property def cy(self) -> float: return self.y + self.h / 2 def _row(y: float, x: float, keys: list[tuple[str, float] | str]) -> list[Key]: out = [] for k in keys: label, w = (k, 1.0) if isinstance(k, str) else k out.append(Key(label, x, y, w)) x += w return out def _build() -> list[Key]: keys = [Key("Esc", 0, 0)] for group, start in ((("F1", "F2", "F3", "F4"), 1.25), (("F5", "F6", "F7", "F8"), 5.5), (("F9", "F10", "F11", "F12"), 9.75)): keys += _row(0, start, list(group)) keys.append(Key("Entf", 15, 0)) keys += _row(1.25, 0, ["^", *"1234567890", "ß", "´", ("⌫", 2.0), "Pos1"]) keys += _row(2.25, 0, [("Tab", 1.5), *"QWERTZUIOP", "Ü", "+"]) keys.append(Key("↵", 13.5, 2.25, 1.5, 2.0, iso_enter=True)) keys.append(Key("Bild↑", 15, 2.25)) keys += _row(3.25, 0, [("Caps", 1.75), *"ASDFGHJKL", "Ö", "Ä", "#"]) keys.append(Key("Bild↓", 15, 3.25)) keys += _row(4.25, 0, [("⇧", 1.25), "<", *"YXCVBNM", ",", ".", "-", ("⇧", 1.75), "↑"]) keys += _row(5.25, 0, [("Strg", 1.25), ("Win", 1.25), ("Alt", 1.25), ("", 6.25), "AltGr", "Fn", "Strg", "←", "↓", "→"]) return keys KEYS: list[Key] = _build() WIDTH = 16.0 HEIGHT = 6.25