{"record":{"id":"f70f7c01e7f5511f","repo":"grafana/k6","slug":"key-down-w","errorCode":null,"errorMessage":"key down: %w","messagePattern":"key down: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/keyboard.go","lineNumber":313,"sourceCode":"\t\t\tkk = append(kk, s.String())\n\t\t\ts.Reset()\n\t\t} else {\n\t\t\ts.WriteRune(r)\n\t\t}\n\t}\n\tkk = append(kk, s.String())\n\n\treturn kk\n}\n\nfunc (k *Keyboard) press(key string, opts KeyboardOptions) error {\n\tif opts.Delay > 0 {\n\t\tif err := wait(k.ctx, opts.Delay); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := k.down(key); err != nil {\n\t\treturn fmt.Errorf(\"key down: %w\", err)\n\t}\n\treturn k.up(key)\n}\n\nfunc (k *Keyboard) typ(text string, opts KeyboardOptions) error {\n\tlayout := keyboardlayout.GetKeyboardLayout(k.layoutName)\n\tfor _, c := range text {\n\t\tif opts.Delay > 0 {\n\t\t\tif err := wait(k.ctx, opts.Delay); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tkeyInput := keyboardlayout.KeyInput(c)\n\t\tif _, ok := layout.ValidKeys[keyInput]; ok {\n\t\t\tif err := k.press(string(c), opts); err != nil {\n\t\t\t\treturn fmt.Errorf(\"pressing key: %w\", err)\n\t\t\t}\n\t\t\tcontinue","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/keyboard.go#L295-L331","documentation":"Wrap of Keyboard.down inside the single-key press helper: press() optionally waits the configured delay, dispatches key down, then key up. This wrap isolates the down-half failure — either the key failed layout validation (invalid name for the active layout) or the CDP dispatchKeyEvent call failed because the session/context was closed. It is the innermost wrap beneath Keyboard.Press's broader 'pressing key' error.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/keyboard.go:313 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid, correctly-cased key name for the layout ('a', 'F5', 'Escape')","Ensure the page session is alive when the press executes","Prefer page/locator press helpers which manage focus and retries"],"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"}