Register key event on Mac & Windows.