{"record":{"id":"e9713d90c24ea196","repo":"grafana/k6","slug":"q-is-not-a-valid-key-for-layout-q","errorCode":null,"errorMessage":"%q is not a valid key for layout %q","messagePattern":"%q is not a valid key for layout %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/keyboard.go","lineNumber":105,"sourceCode":"\n// Type sends a press message to a session target for each character in text.\n// It delays the action if `Delay` option is specified.\n//\n// It sends an insertText message if a character is not among\n// valid characters in the keyboard's layout.\nfunc (k *Keyboard) Type(text string, kbdOpts KeyboardOptions) error {\n\tif err := k.typ(text, kbdOpts); err != nil {\n\t\treturn fmt.Errorf(\"typing text: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (k *Keyboard) down(key string) error {\n\tkey = k.platformSpecificResolution(key)\n\n\tkeyInput := keyboardlayout.KeyInput(key)\n\tif _, ok := k.layout.ValidKeys[keyInput]; !ok {\n\t\treturn fmt.Errorf(\"%q is not a valid key for layout %q\", key, k.layoutName)\n\t}\n\n\tkeyDef := k.keyDefinitionFromKey(keyInput)\n\tk.modifiers |= k.modifierBitFromKeyName(keyDef.Key)\n\ttext := keyDef.Text\n\n\tk.pressedKeysMu.Lock()\n\t_, autoRepeat := k.pressedKeys[keyDef.KeyCode]\n\tk.pressedKeys[keyDef.KeyCode] = struct{}{}\n\tk.pressedKeysMu.Unlock()\n\n\tkeyType := input.KeyDown\n\tif text == \"\" {\n\t\tkeyType = input.KeyRawDown\n\t}\n\n\taction := input.DispatchKeyEvent(keyType).\n\t\tWithModifiers(input.Modifier(k.modifiers)).","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/keyboard.go#L87-L123","documentation":"Layout-membership guard in Keyboard.down: before dispatching anything, the key string is resolved through platform-specific mappings and checked against the active keyboard layout's ValidKeys set (\"us\" layout by default). This error means the resolved key is not present in that set — a misspelled or non-existent key name like 'Del' instead of 'Delete', or an untranslated platform-specific key.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/keyboard.go:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use exact key names from the US layout: 'Delete', 'Backspace', 'ArrowLeft', 'PageDown', etc.","Check the k6 browser keyboard documentation for the supported key list","For single characters, use type()/insertText() rather than down()/up()"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}