Skip to content

Generic expandable keyboard layout system and Spanish support - #494

Open
marc-romu wants to merge 3 commits into
mulaRahul:mainfrom
marc-romu:main
Open

Generic expandable keyboard layout system and Spanish support#494
marc-romu wants to merge 3 commits into
mulaRahul:mainfrom
marc-romu:main

Conversation

@marc-romu

@marc-romu marc-romu commented Jun 29, 2026

Copy link
Copy Markdown

Summary

This PR introduces a new generic, auto-discoverable keyboard layout system to provide compatibility beyond the currently supported US English layout. Adding a new layout now requires dropping a single file into src/lib/layouts/ — no UI or store changes needed. Spanish (Spain), German, French and Colemak0 layouts are included as the first non-US layouts, together with Windows fixes for AltGr and scancode-based key identification.

What changed

  • Auto-discovering layout engine: src/lib/layouts/*.ts files are collected automatically at build time via import.meta.glob. Each file exports an id, human-readable name and a per-key overrides map. The settings dropdown, keycap renderer, filter grid, and shortcut recorder all consume this dynamically.
  • Scancode-based key resolution (Windows): the rdev Windows hook now uses get_win_key(vk_code, scancode) instead of raw virtual-key codes. This identifies physical keys consistently even when the active Windows layout is not US English.
  • Generic AltGr support: detects the Windows low-level-hook quirk where AltGr is delivered as Ctrl+Alt, merges the two events back into a single AltGr press/release, and suppresses the phantom ControlLeft/Alt spam. This works for any AltGr layout (Spanish, German, French, etc.).
  • Spanish (Spain) layout: adds the first non-US layout file (es.ts) with overrides for ñ, ç, ´, ^, ¡/¿, º/ª, etc.
  • Additional layouts: German, French and Colemak.
  • Version bump: 2.1.12.1.2.

How to add another layout

Create src/lib/layouts/<id>.ts:

import type { KeyboardLayoutDef } from "./types";

const fr: KeyboardLayoutDef = {
    id: "fr",
    name: "French (AZERTY)",
    overrides: {
        KeyQ: { label: "A" },
        KeyW: { label: "Z" },
        SemiColon: { label: "M" },
        // ...etc
    },
};

export default fr;

No other files need to be touched.

Fixes

Issue #15
Issue #150
Discussion #16

Copilot AI review requested due to automatic review settings June 29, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Adds new layout definitions under src/lib/layouts and an IntlBackslash base key so the ISO key between left Shift and Z is displayed correctly.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@marc-romu

Copy link
Copy Markdown
Author

The compilation for this PR is downloadable here: https://github.com/marc-romu/keyviz/releases/tag/2.1.2-dev.260822

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants