Add detect undo key javascript