Sync up the caps/numlock state properly without sending key events. Partially fixes Bugzilla #2736 and #3125.