Keyboard API

KeyboardEvent.code names a physical key (KeyW is the same physical key on every layout), while key is the character it types (Handling Input Events). The Chromium-only Keyboard API serves fullscreen games and remote desktops: getLayoutMap() tells you what to print in "Move with W A S D", and lock() captures keys the browser or OS normally keeps, such as Escape, until unlock(). Headless Chrome 1 has a US layout:

Labeling keys for the user's layout and capturing reserved keysJavaScript
const layout = await navigator.keyboard.getLayoutMap();
const keys = ['KeyW', 'KeyA', 'KeyS', 'KeyD'].map((code) => layout.get(code).toUpperCase());
console.log(`Move with ${keys.join(' ')} (${layout.size} keys mapped)`);
await navigator.keyboard.lock(['KeyW', 'KeyA', 'KeyS', 'KeyD', 'Escape']);
Output
Move with W A S D (48 keys mapped)

On a French AZERTY keyboard the same code prints Z Q S D.