Module emscripten
emscripten API.
Description
The functions in this module broadly reflect emscripten’s API and obviously are only implemented for the emscripten platform.
See Emscripten’s API documentation for more information about these APIs.
The counterpart of functions defined in this module are two main Javascript functions that can be used to send messages to Erlang.
Module.cast('some_proc', 'message')
await Module.call('some_proc', 'message')
These respectively send the following messages to Erlang process registered as some_proc
:
{emscripten, {cast, <<"message">>}}
{emscripten, {call, Promise, <<"message">>}}
Promise should be passed to promise_resolve/1,2
or promise_reject/1,2
as
documented below.
Data Types
focus_event()
focus_event() = #{node_name => unicode:unicode_binary(), id => unicode:unicode_binary()}
html5_target()
html5_target() = window | document | screen | iodata()
keyboard_event()
keyboard_event() = #{timestamp => float(), location => integer(), ctrl_key => boolean(), shift_key => boolean(), alt_key => boolean(), meta_key => boolean(), repeat => boolean(), char_code => integer(), key_code => integer(), which => integer(), key => unicode:unicode_binary(), code => unicode:unicode_binary(), char_value => unicode:unicode_binary(), locale => unicode:unicode_binary()}
listener_handle()
abstract datatype: listener_handle()
mouse_event()
mouse_event() = #{timestamp => float(), screen_x => integer(), screen_y => integer(), client_x => integer(), client_y => integer(), ctrl_key => boolean(), shift_key => boolean(), alt_key => boolean(), meta_key => boolean(), button => integer(), buttons => integer(), movement_x => integer(), movement_y => integer(), target_x => integer(), target_y => integer(), padding => integer()}
promise()
abstract datatype: promise()
register_error_reason()
register_error_reason() = not_supported | failed_not_deferred | invalid_target | unknown_target | failed | no_data | timed_out | integer()
register_option()
register_option() = {use_capture, boolean()} | {prevent_default, boolean()}
register_options()
register_options() = boolean() | [register_option()]
register_result()
register_result() = {ok, listener_handle()} | {ok, listener_handle(), deferred} | {error, register_error_reason()}
run_script_opt()
run_script_opt() = main_thread | async
touch_event()
touch_event() = #{timestamp => float(), ctrl_key => boolean(), shift_key => boolean(), alt_key => boolean(), meta_key => boolean(), touches => [touch_point()]}
touch_point()
touch_point() = #{identifier => integer(), screen_x => integer(), screen_y => integer(), client_x => integer(), client_y => integer(), page_x => integer(), page_y => integer(), is_changed => boolean(), on_target => boolean(), target_x => integer(), target_y => integer()}
ui_event()
ui_event() = #{detail => integer(), document_body_client_width => integer(), document_body_client_height => integer(), window_inner_width => integer(), window_inner_height => integer(), window_outer_width => integer(), window_outer_height => integer(), scroll_top => integer(), scroll_left => integer()}
wheel_event()
wheel_event() = #{timestamp => float(), screen_x => integer(), screen_y => integer(), client_x => integer(), client_y => integer(), ctrl_key => boolean(), shift_key => boolean(), alt_key => boolean(), meta_key => boolean(), button => integer(), buttons => integer(), movement_x => integer(), movement_y => integer(), target_x => integer(), target_y => integer(), padding => integer(), delta_x => integer(), delta_y => integer(), delta_z => integer(), delta_mode => integer()}
Function Index
Function Details
promise_reject/1
promise_reject(Promise::promise()) -> ok
Equivalent to promise_reject(_Promise, 0)
.
promise_reject/2
promise_reject(Promise::promise(), Value::integer() | iodata()) -> ok
Reject a promise with a given result.
This is similar to promise_resolve
except the promise is rejected.
promise_resolve/1
promise_resolve(Promise::promise()) -> ok
Equivalent to promise_resolve(_Promise, 0)
.
promise_resolve/2
promise_resolve(Promise::promise(), Value::integer() | iodata()) -> ok
Successfully resolve a promise with a given result.
A promise is currently only obtained through synchronous calls using
Module.call()
javascript function.
If Javascript calls:
await Module.call('some_proc', 'message')
and if an Erlang process is registered as some_proc
, then the process
will receive a message:
{emscripten, {call, Promise, <<"message">>}}`''
and the Javascript caller will wait until `promise_resolve` or `promise_reject`
is called. If the process doesn't exist, the promise will be rejected with
'no_proc'. Likewise if the Promise is garbage collected by the Erlang VM.
<a name="register_blur_callback-1"></a>
### register_blur_callback/1 ###
<pre><code>
register_blur_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_blur_callback(_Target, [])`](#register_blur_callback-2).
<a name="register_blur_callback-2"></a>
### register_blur_callback/2 ###
<pre><code>
register_blur_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for blur events.
Events are sent as:
{emscripten, {blur, focus_event()}}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_blur_callback-3"></a>
### register_blur_callback/3 ###
<pre><code>
register_blur_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for blur events.
Events are sent as:
{emscripten, {blur, focus_event()}, UserData}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_click_callback-1"></a>
### register_click_callback/1 ###
<pre><code>
register_click_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_click_callback(_Target, [])`](#register_click_callback-2).
<a name="register_click_callback-2"></a>
### register_click_callback/2 ###
<pre><code>
register_click_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for click events.
Events are sent as:
{emscripten, {click, mouse_event()}}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_click_callback-3"></a>
### register_click_callback/3 ###
<pre><code>
register_click_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for click events.
Events are sent as:
{emscripten, {click, mouse_event()}, UserData}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_dblclick_callback-1"></a>
### register_dblclick_callback/1 ###
<pre><code>
register_dblclick_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_dblclick_callback(_Target, [])`](#register_dblclick_callback-2).
<a name="register_dblclick_callback-2"></a>
### register_dblclick_callback/2 ###
<pre><code>
register_dblclick_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for dblclick events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_dblclick_callback-3"></a>
### register_dblclick_callback/3 ###
<pre><code>
register_dblclick_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for dblclick events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_focus_callback-1"></a>
### register_focus_callback/1 ###
<pre><code>
register_focus_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_focus_callback(_Target, [])`](#register_focus_callback-2).
<a name="register_focus_callback-2"></a>
### register_focus_callback/2 ###
<pre><code>
register_focus_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for focus events.
__See also:__ [register_blur_callback/2](#register_blur_callback-2).
<a name="register_focus_callback-3"></a>
### register_focus_callback/3 ###
<pre><code>
register_focus_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for focus events.
__See also:__ [register_blur_callback/2](#register_blur_callback-2).
<a name="register_focusin_callback-1"></a>
### register_focusin_callback/1 ###
<pre><code>
register_focusin_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_focusin_callback(_Target, [])`](#register_focusin_callback-2).
<a name="register_focusin_callback-2"></a>
### register_focusin_callback/2 ###
<pre><code>
register_focusin_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for focusin events.
__See also:__ [register_blur_callback/2](#register_blur_callback-2).
<a name="register_focusin_callback-3"></a>
### register_focusin_callback/3 ###
<pre><code>
register_focusin_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for focusin events.
__See also:__ [register_blur_callback/2](#register_blur_callback-2).
<a name="register_focusout_callback-1"></a>
### register_focusout_callback/1 ###
<pre><code>
register_focusout_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_focusout_callback(_Target, [])`](#register_focusout_callback-2).
<a name="register_focusout_callback-2"></a>
### register_focusout_callback/2 ###
<pre><code>
register_focusout_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for focusout events.
__See also:__ [register_blur_callback/2](#register_blur_callback-2).
<a name="register_focusout_callback-3"></a>
### register_focusout_callback/3 ###
<pre><code>
register_focusout_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for focusout events.
__See also:__ [register_blur_callback/2](#register_blur_callback-2).
<a name="register_keydown_callback-1"></a>
### register_keydown_callback/1 ###
<pre><code>
register_keydown_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_keydown_callback(_Target, [])`](#register_keydown_callback-2).
<a name="register_keydown_callback-2"></a>
### register_keydown_callback/2 ###
<pre><code>
register_keydown_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for keydown events.
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_keydown_callback-3"></a>
### register_keydown_callback/3 ###
<pre><code>
register_keydown_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for keydown events.
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_keypress_callback-1"></a>
### register_keypress_callback/1 ###
<pre><code>
register_keypress_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_keypress_callback(_Target, [])`](#register_keypress_callback-2).
<a name="register_keypress_callback-2"></a>
### register_keypress_callback/2 ###
<pre><code>
register_keypress_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for keypress events.
This function registers with no user data and events are sent as:
{emscripten, {keypress, keyboard_event()}}
__See also:__ [register_keypress_callback/3](#register_keypress_callback-3).
<a name="register_keypress_callback-3"></a>
### register_keypress_callback/3 ###
<pre><code>
register_keypress_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for keypress events.
This function registers keypress events on a given target.
Target can be specified as special atoms `window` for Javascript's window,
`document` for window.document. `screen` is also supported, but it doesn't
seem to work, see [`https://github.com/emscripten-core/emscripten/issues/19865`](https://github.com/emscripten-core/emscripten/issues/19865)
Second parameter specifies options which can be a `boolean()` to match
`useCapture` in Emscripten's API. Alternatively, the option can be a proplist()
with `use_capture` and `prevent_default` keys. `prevent_default` determines
what the handler should return to Javascript, `true` meaning that the default
should be prevented.
Third parameter is user data that is passed back. Indeed, when an event
occurs, the following message is sent to the process that registered the
event:
{emscripten, {keypress, keyboard_event()}, UserData}
The function eventually returns a `listener_handle()` or an error. The
handler is an opaque resource that actually contains a copy of `UserData`.
Please note that if the calling process dies, the callback and any callback
for the same event on the same target are unregistered.
<a name="register_keyup_callback-1"></a>
### register_keyup_callback/1 ###
<pre><code>
register_keyup_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_keyup_callback(_Target, [])`](#register_keyup_callback-2).
<a name="register_keyup_callback-2"></a>
### register_keyup_callback/2 ###
<pre><code>
register_keyup_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for keyup events.
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_keyup_callback-3"></a>
### register_keyup_callback/3 ###
<pre><code>
register_keyup_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for keyup events.
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_mousedown_callback-1"></a>
### register_mousedown_callback/1 ###
<pre><code>
register_mousedown_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_mousedown_callback(_Target, [])`](#register_mousedown_callback-2).
<a name="register_mousedown_callback-2"></a>
### register_mousedown_callback/2 ###
<pre><code>
register_mousedown_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mousedown events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mousedown_callback-3"></a>
### register_mousedown_callback/3 ###
<pre><code>
register_mousedown_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mousedown events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseenter_callback-1"></a>
### register_mouseenter_callback/1 ###
<pre><code>
register_mouseenter_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_mouseenter_callback(_Target, [])`](#register_mouseenter_callback-2).
<a name="register_mouseenter_callback-2"></a>
### register_mouseenter_callback/2 ###
<pre><code>
register_mouseenter_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseenter events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseenter_callback-3"></a>
### register_mouseenter_callback/3 ###
<pre><code>
register_mouseenter_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseenter events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseleave_callback-1"></a>
### register_mouseleave_callback/1 ###
<pre><code>
register_mouseleave_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_mouseleave_callback(_Target, [])`](#register_mouseleave_callback-2).
<a name="register_mouseleave_callback-2"></a>
### register_mouseleave_callback/2 ###
<pre><code>
register_mouseleave_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseleave events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseleave_callback-3"></a>
### register_mouseleave_callback/3 ###
<pre><code>
register_mouseleave_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseleave events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mousemove_callback-1"></a>
### register_mousemove_callback/1 ###
<pre><code>
register_mousemove_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_mousemove_callback(_Target, [])`](#register_mousemove_callback-2).
<a name="register_mousemove_callback-2"></a>
### register_mousemove_callback/2 ###
<pre><code>
register_mousemove_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mousemove events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mousemove_callback-3"></a>
### register_mousemove_callback/3 ###
<pre><code>
register_mousemove_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mousemove events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseout_callback-1"></a>
### register_mouseout_callback/1 ###
<pre><code>
register_mouseout_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_mouseout_callback(_Target, [])`](#register_mouseout_callback-2).
<a name="register_mouseout_callback-2"></a>
### register_mouseout_callback/2 ###
<pre><code>
register_mouseout_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseout events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseout_callback-3"></a>
### register_mouseout_callback/3 ###
<pre><code>
register_mouseout_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseout events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseover_callback-1"></a>
### register_mouseover_callback/1 ###
<pre><code>
register_mouseover_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_mouseover_callback(_Target, [])`](#register_mouseover_callback-2).
<a name="register_mouseover_callback-2"></a>
### register_mouseover_callback/2 ###
<pre><code>
register_mouseover_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseover events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseover_callback-3"></a>
### register_mouseover_callback/3 ###
<pre><code>
register_mouseover_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseover events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseup_callback-1"></a>
### register_mouseup_callback/1 ###
<pre><code>
register_mouseup_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_mouseup_callback(_Target, [])`](#register_mouseup_callback-2).
<a name="register_mouseup_callback-2"></a>
### register_mouseup_callback/2 ###
<pre><code>
register_mouseup_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseup events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_mouseup_callback-3"></a>
### register_mouseup_callback/3 ###
<pre><code>
register_mouseup_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for mouseup events.
__See also:__ [register_click_callback/2](#register_click_callback-2).
<a name="register_resize_callback-1"></a>
### register_resize_callback/1 ###
<pre><code>
register_resize_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_resize_callback(_Target, [])`](#register_resize_callback-2).
<a name="register_resize_callback-2"></a>
### register_resize_callback/2 ###
<pre><code>
register_resize_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for resize events.
Events are sent as:
{emscripten, {resize, ui_event()}}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_resize_callback-3"></a>
### register_resize_callback/3 ###
<pre><code>
register_resize_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for resize events.
Events are sent as:
{emscripten, {resize, ui_event()}, UserData}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_scroll_callback-1"></a>
### register_scroll_callback/1 ###
<pre><code>
register_scroll_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_scroll_callback(_Target, [])`](#register_scroll_callback-2).
<a name="register_scroll_callback-2"></a>
### register_scroll_callback/2 ###
<pre><code>
register_scroll_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for scroll events.
__See also:__ [register_resize_callback/2](#register_resize_callback-2).
<a name="register_scroll_callback-3"></a>
### register_scroll_callback/3 ###
<pre><code>
register_scroll_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for scroll events.
__See also:__ [register_resize_callback/2](#register_resize_callback-2).
<a name="register_touchcancel_callback-1"></a>
### register_touchcancel_callback/1 ###
<pre><code>
register_touchcancel_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_touchcancel_callback(_Target, [])`](#register_touchcancel_callback-2).
<a name="register_touchcancel_callback-2"></a>
### register_touchcancel_callback/2 ###
<pre><code>
register_touchcancel_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchcancel events.
__See also:__ [register_touchstart_callback/2](#register_touchstart_callback-2).
<a name="register_touchcancel_callback-3"></a>
### register_touchcancel_callback/3 ###
<pre><code>
register_touchcancel_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchcancel events.
__See also:__ [register_touchstart_callback/2](#register_touchstart_callback-2).
<a name="register_touchend_callback-1"></a>
### register_touchend_callback/1 ###
<pre><code>
register_touchend_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_touchend_callback(_Target, [])`](#register_touchend_callback-2).
<a name="register_touchend_callback-2"></a>
### register_touchend_callback/2 ###
<pre><code>
register_touchend_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchend events.
__See also:__ [register_touchstart_callback/2](#register_touchstart_callback-2).
<a name="register_touchend_callback-3"></a>
### register_touchend_callback/3 ###
<pre><code>
register_touchend_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchend events.
__See also:__ [register_touchstart_callback/2](#register_touchstart_callback-2).
<a name="register_touchmove_callback-1"></a>
### register_touchmove_callback/1 ###
<pre><code>
register_touchmove_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_touchmove_callback(_Target, [])`](#register_touchmove_callback-2).
<a name="register_touchmove_callback-2"></a>
### register_touchmove_callback/2 ###
<pre><code>
register_touchmove_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchmove events.
__See also:__ [register_touchstart_callback/2](#register_touchstart_callback-2).
<a name="register_touchmove_callback-3"></a>
### register_touchmove_callback/3 ###
<pre><code>
register_touchmove_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchmove events.
__See also:__ [register_touchstart_callback/2](#register_touchstart_callback-2).
<a name="register_touchstart_callback-1"></a>
### register_touchstart_callback/1 ###
<pre><code>
register_touchstart_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_touchstart_callback(_Target, [])`](#register_touchstart_callback-2).
<a name="register_touchstart_callback-2"></a>
### register_touchstart_callback/2 ###
<pre><code>
register_touchstart_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchstart events.
Events are sent as:
{emscripten, {touchstart, touch_event()}}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_touchstart_callback-3"></a>
### register_touchstart_callback/3 ###
<pre><code>
register_touchstart_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for touchstart events.
Events are sent as:
{emscripten, {touchstart, touch_event()}, UserData}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_wheel_callback-1"></a>
### register_wheel_callback/1 ###
<pre><code>
register_wheel_callback(Target::<a href="#type.md5_target">html5_target()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Equivalent to [`register_wheel_callback(_Target, [])`](#register_wheel_callback-2).
<a name="register_wheel_callback-2"></a>
### register_wheel_callback/2 ###
<pre><code>
register_wheel_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for wheel events.
Events are sent as:
{emscripten, {wheel, wheel_event()}}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="register_wheel_callback-3"></a>
### register_wheel_callback/3 ###
<pre><code>
register_wheel_callback(Target::<a href="#type.md5_target">html5_target()</a>, Options::<a href="#type-register_options">register_options()</a>, UserData::any()) -> <a href="#type-register_result">register_result()</a>
</code></pre>
<br />
Register for wheel events.
Events are sent as:
{emscripten, {wheel, mouse_event()}, UserData}
__See also:__ [register_keypress_callback/2](#register_keypress_callback-2).
<a name="run_script-1"></a>
### run_script/1 ###
<pre><code>
run_script(Script::iodata()) -> ok
</code></pre>
<br />
Equivalent to [`run_script(_Script, [])`](#run_script-2).
<a name="run_script-2"></a>
### run_script/2 ###
<pre><code>
run_script(Script::iodata(), Options::[<a href="#type-run_script_opt">run_script_opt()</a>]) -> ok
</code></pre>
<br />
returns: ok
Run a script.
By default, the script is run in the current worker thread, which arguably
may not be very useful. Please note that exception handling is disabled, so
the script should not throw and should compile, otherwise this will crash
the VM.
<a name="unregister_blur_callback-1"></a>
### unregister_blur_callback/1 ###
<pre><code>
unregister_blur_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a blur event handler.
__See also:__ [unregister_keypress_callback/1](#unregister_keypress_callback-1).
<a name="unregister_click_callback-1"></a>
### unregister_click_callback/1 ###
<pre><code>
unregister_click_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a click event handler.
__See also:__ [unregister_keypress_callback/1](#unregister_keypress_callback-1).
<a name="unregister_dblclick_callback-1"></a>
### unregister_dblclick_callback/1 ###
<pre><code>
unregister_dblclick_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a dblclick event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_focus_callback-1"></a>
### unregister_focus_callback/1 ###
<pre><code>
unregister_focus_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a focus event handler.
__See also:__ [unregister_blur_callback/1](#unregister_blur_callback-1).
<a name="unregister_focusin_callback-1"></a>
### unregister_focusin_callback/1 ###
<pre><code>
unregister_focusin_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a focusin event handler.
__See also:__ [unregister_blur_callback/1](#unregister_blur_callback-1).
<a name="unregister_focusout_callback-1"></a>
### unregister_focusout_callback/1 ###
<pre><code>
unregister_focusout_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a focusout event handler.
__See also:__ [unregister_blur_callback/1](#unregister_blur_callback-1).
<a name="unregister_keydown_callback-1"></a>
### unregister_keydown_callback/1 ###
<pre><code>
unregister_keydown_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a keydown event handler.
__See also:__ [unregister_keypress_callback/1](#unregister_keypress_callback-1).
<a name="unregister_keypress_callback-1"></a>
### unregister_keypress_callback/1 ###
<pre><code>
unregister_keypress_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
returns: ok or an error
Unregister a keypress listener.
To match Emscripten's API, this function can take a target. This function
unregisters every keypress listeners on the specified target.
Alternatively, this function can take a listener_handle() returned by
`register_keypress_callback/1,2,3`. This will still unregister every
keypress listeners on the same target.
Passing a `listener_handle()` is recommended to avoid surprises and for
memory efficiency. If a handle is passed, it can then be garbage collected.
If a handle is not passed, but the process dies, every keypress listener
on the same target will be unregistered, including listeners that were
later registered. This is a known limitation of the implementation that
favored avoiding memory leaks and crashes.
<a name="unregister_keyup_callback-1"></a>
### unregister_keyup_callback/1 ###
<pre><code>
unregister_keyup_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a keyup event handler.
__See also:__ [unregister_keypress_callback/1](#unregister_keypress_callback-1).
<a name="unregister_mousedown_callback-1"></a>
### unregister_mousedown_callback/1 ###
<pre><code>
unregister_mousedown_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a mousedown event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_mouseenter_callback-1"></a>
### unregister_mouseenter_callback/1 ###
<pre><code>
unregister_mouseenter_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a mouseenter event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_mouseleave_callback-1"></a>
### unregister_mouseleave_callback/1 ###
<pre><code>
unregister_mouseleave_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a mouseleave event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_mousemove_callback-1"></a>
### unregister_mousemove_callback/1 ###
<pre><code>
unregister_mousemove_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a mousemove event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_mouseout_callback-1"></a>
### unregister_mouseout_callback/1 ###
<pre><code>
unregister_mouseout_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a mouseout event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_mouseover_callback-1"></a>
### unregister_mouseover_callback/1 ###
<pre><code>
unregister_mouseover_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a mouseover event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_mouseup_callback-1"></a>
### unregister_mouseup_callback/1 ###
<pre><code>
unregister_mouseup_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a mouseup event handler.
__See also:__ [unregister_click_callback/1](#unregister_click_callback-1).
<a name="unregister_resize_callback-1"></a>
### unregister_resize_callback/1 ###
<pre><code>
unregister_resize_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a resize event handler.
__See also:__ [unregister_keypress_callback/1](#unregister_keypress_callback-1).
<a name="unregister_scroll_callback-1"></a>
### unregister_scroll_callback/1 ###
<pre><code>
unregister_scroll_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a scroll event handler.
__See also:__ [unregister_resize_callback/1](#unregister_resize_callback-1).
<a name="unregister_touchcancel_callback-1"></a>
### unregister_touchcancel_callback/1 ###
<pre><code>
unregister_touchcancel_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a touchcancel event handler.
__See also:__ [unregister_touchstart_callback/1](#unregister_touchstart_callback-1).
<a name="unregister_touchend_callback-1"></a>
### unregister_touchend_callback/1 ###
<pre><code>
unregister_touchend_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a touchend event handler.
__See also:__ [unregister_touchstart_callback/1](#unregister_touchstart_callback-1).
<a name="unregister_touchmove_callback-1"></a>
### unregister_touchmove_callback/1 ###
<pre><code>
unregister_touchmove_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a touchmove event handler.
__See also:__ [unregister_touchstart_callback/1](#unregister_touchstart_callback-1).
<a name="unregister_touchstart_callback-1"></a>
### unregister_touchstart_callback/1 ###
<pre><code>
unregister_touchstart_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a touchstart event handler.
__See also:__ [unregister_keypress_callback/1](#unregister_keypress_callback-1).
<a name="unregister_wheel_callback-1"></a>
### unregister_wheel_callback/1 ###
<pre><code>
unregister_wheel_callback(TargetOrHandle::<a href="#type.md5_target">html5_target()</a> | <a href="#type-listener_handle">listener_handle()</a>) -> ok | {error, <a href="#type-register_error_reason">register_error_reason()</a>}
</code></pre>
<br />
Unregister a wheel event handler.
__See also:__ [unregister_keypress_callback/1](#unregister_keypress_callback-1).