implement most key typing logic