Input
内部のようなChakra UI要素がありFormik
Form
ます。
import { Formik, useField, Form, useFormikContext } from "formik";
import {
Input } from "@chakra-ui/react";
<Formik
// setup stuff
>
<Form>
<Input
id={field.name}
onChange={field.onChange}
placeholder={placeholder}
value={field.value}
onKeyPress={(event) => {
console.log("event = ", event)
console.log("event.key = ", event.key)
if (event.key === "Backspace") {
console.log("pressed backspace")
}
}}
/>
delete
Google Chrome バージョン 91.0.4472.114 (公式ビルド) (x86_64) で macOS 10.15.7のキーを押しても、アルファベット キーのプリントアウトを取得できますが、プリントアウトを取得できません。
誰が私が間違っているのか考えていますか?
これは、event
キーボードで文字 R を押したときの出力です。
event =
SyntheticBaseEvent {_reactName: "onKeyPress", _targetInst: null, type: "keypress", nativeEvent: KeyboardEvent, target: input#player3.chakra-input.css-1q4t59, …}
altKey: false
bubbles: true
cancelable: true
charCode: 82
code: "KeyS"
ctrlKey: false
currentTarget: null
defaultPrevented: false
detail: 0
eventPhase: 3
getModifierState: ƒ modifierStateGetter(keyArg)
isDefaultPrevented: ƒ functionThatReturnsFalse()
isPropagationStopped: ƒ functionThatReturnsFalse()
isTrusted: true
key: "R"
keyCode: 0
locale: undefined
location: 0
metaKey: false
nativeEvent: KeyboardEvent {isTrusted: true, key: "R", code: "KeyS", location: 0, ctrlKey: false, …}
repeat: false
shiftKey: true
target: input#player3.chakra-input.css-1q4t59
timeStamp: 643207.7999999998
type: "keypress"
view: Window {window: Window, self: Window, document: document, name: "", location: Location, …}
which: 82
_reactName: "onKeyPress"
_targetInst: null