Disable key entry in Material UI TextField
Solution 1:
This seemed to work in code sandbox
import "./styles.css";
import React, { useState } from "react";
import TextField from "@material-ui/core/TextField";
export default function App() {
const [value, setValue] = useState("0.0");
return (
<TextField
type="number"
value={value}
variant="outlined"
inputProps={{
maxLength: 13,
step: "2000",
}}
onChange={(evt) => setValue(evt.target.value)}
onKeyPress={(e)=>{e.preventDefault();return false}}
/>
);
}