【发布时间】:2021-05-17 23:05:46
【问题描述】:
我无法使用此代码获取输入值。我尝试使用 onKeyUp, onKeyDown 和 onKeyPress 但这些都不起作用,因为没有返回值。通常使用onChange 属性获取值,但它会触发每个输入的新字符。
<TextField
style={{ margin: 8 }}
placeholder="Add a task"
fullWidth
margin="normal"
onKeyPress={(e) => {
if (e.key === "Enter") {
console.log("Enter key pressed");
// write your functionality here
}
}}
/>;
【问题讨论】:
标签: reactjs typescript material-ui