Fix for keyevent

- Make sure keyevent works if metastate is null.
- Added a default keyInjectionDelay = 100ms (default value is 0), so that the text input is similar to how a user inputs the text.