JSFiddle - React, Tailwind, and code Playground

HTML

<form action="">

  <input type="text" onkeypress="color('green')" onkeyup="color('white')" name="txtName">

                                                                                </form>

CSS

input {
  background: orange;
}

JavaScript

function color(col) { document.forms[0].txtName.style.background=col }