For most purposes you don't need Javascript: simply configure the On enter property of the textbox.
If you want to use the onClick event you should create a custom widget which places a textbox on your page and enables the onclick event.
Third solution: Use the HTML Snippet widget from the appstore, and select the Javascript option. This is handy for running little bits of JS without having to create a full-scale widget that may only be used on one screen.