Changed document.onkeypress to document.addEventListener('keypress', ...