How to close Soft Keyboard?


I’m developing an app on an Android phone phone which requires the soft keyboard. This works fine however closing the keyboard on pressing the enter key is proving to be problematic.

I’m using:

stage.focus = null

to take the focus away from the text field which should work, however this crashes my app with the following error:

The application App (process air.myappname) has stopped unexpectedly. Please try again.

Does anyone have any ideas as to why this would be happening?