Optimize key-up handler