rewrite work with keyboard: more flexible and look pretty nice