I cannot get input value with this code. I tried with onKeyUp, onKeyDown and onKeyPress but these are not worked because not return the value. Normally get value with onChange property but it triggers every entered new character.
<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 } }} />;