{"record":{"id":"449686a8cfdf2582","repo":"grafana/k6","slug":"s-is-not-a-valid-key-for-layout-s","errorCode":null,"errorMessage":"'%s' is not a valid key for layout '%s'","messagePattern":"'(.+?)' is not a valid key for layout '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/keyboard.go","lineNumber":144,"sourceCode":"\t\tWithCode(keyDef.Code).\n\t\tWithLocation(keyDef.Location).\n\t\tWithIsKeypad(keyDef.Location == 3).\n\t\tWithText(text).\n\t\tWithUnmodifiedText(text).\n\t\tWithAutoRepeat(autoRepeat)\n\tif err := action.Do(cdp.WithExecutor(k.ctx, k.session)); err != nil {\n\t\treturn fmt.Errorf(\"dispatching key event down: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (k *Keyboard) up(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(\"'%s' is not a valid key for layout '%s'\", key, k.layoutName)\n\t}\n\n\tkeyDef := k.keyDefinitionFromKey(keyInput)\n\tk.modifiers &= ^k.modifierBitFromKeyName(keyDef.Key)\n\tk.pressedKeysMu.Lock()\n\tdelete(k.pressedKeys, keyDef.KeyCode)\n\tk.pressedKeysMu.Unlock()\n\n\taction := input.DispatchKeyEvent(input.KeyUp).\n\t\tWithModifiers(input.Modifier(k.modifiers)).\n\t\tWithKey(keyDef.Key).\n\t\tWithWindowsVirtualKeyCode(keyDef.KeyCode).\n\t\tWithCode(keyDef.Code).\n\t\tWithLocation(keyDef.Location)\n\tif err := action.Do(cdp.WithExecutor(k.ctx, k.session)); err != nil {\n\t\treturn fmt.Errorf(\"dispatching key event up: %w\", err)\n\t}\n","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/keyboard.go#L126-L162","documentation":"Layout-membership guard in Keyboard.up, the release counterpart of the down guard: the key string is checked against the active layout's ValidKeys set, and this error means the key being released is not a recognized key name for that layout. Note it can surface for a valid press key if the up call uses different spelling or casing (e.g., pressing 'Enter' but releasing 'enter').","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/keyboard.go:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use identical, correctly-cased key names for down and up ('Enter', 'Shift', 'ArrowUp')","Prefer press() which derives the release key from the press key automatically","Consult the supported key list in the k6 browser docs"],"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"}