backport keypress fix from sotomayor