A JavaScript key state handler for web apps