This is the line responsible for updating the output:
$write.html($write.html() + character);
$write references a <textarea> element, everything works as expected, however when you change the <textarea> element to in <input> element, the script fails, as an <input> element doesn't have a
Change the above line to this and things will work as expected:
$write.val($write.val() + character);
Hope that helps.