Input text field with onKeyDown not firing onKeyDown event


#1

So I’m using a custom class that is an expanding input text field, and while before I was having an issue of it not allowing backspace, left, or right, following the advice of this post:


I found that it did fix that behavior at least, but their suggested “onKeyDown” event is not firing. I am using typescript to program, so it may look a little different to javascript. I’ve modified the code to exclude the expanding functions and other things, but it still doesn’t fire the onKeyDown event.

<input
  className="native-key-bindings"
  type="text"
  value={value}
  style={{
    width: "100px"
    outline: "none",
    padding: 0
  }}
  placeholder={"Type.."}
  onKeyDown={e => {
    console.log("keydown!")
    if (e.key === "Tab") {
      if (e.shiftKey) {
        //previousInputElement.focus()
      } else {
        //nextInputElement.focus()
      }
    } else if (e.key === "Enter") {
      console.log("pressed enter")
    }
  }}
  onChange={e => {if (onChange !== undefined) onChange()}}
  onClick={e => e.stopPropagation()}
/>

Even when typing normal letters, keyDown does not activate. Any tips or pointing out what I’m missing?