pylayout
pylayout is a Python module for getting and setting the current keyboard layout in Windows. It also includes utilities for detecting the language of input characters and translating text between keyboard layouts.
It supports Windows and linux systems.
Installation
pip install pylayout
Usage
from pylayout import Layout
layout = Layout(use_cache=False)
print("Current layout:", layout.get())
print("Available layouts:", layout.list())
layout.set("uk")
print("New layout:", layout.get())
char = "ї"
print(f"Language for '{char}':", layout.detect_language(char))
print("Translate 'ghbdsn' from 'en' to 'uk':", layout.translate("ghbdsn", "en", "uk"))
Features
- Get the current keyboard layout
- Set the keyboard layout by language code (e.g.,
en, uk)
- List all available keyboard layouts
- Detect the language associated with a given character
- Translate text from one keyboard layout to another (e.g., fix "ghbdsn" typed in the wrong layout)
Fixes
There are some issues on windows so here are some resources to fix them