Question about types of inputs for Extensions

So I was reading through the Extension docs, and I noticed that Extensions cannot use the Keyboard as an input method. Is input only limited to a Mouse, or can I do fancy things with the HTML5 Gamepad API via a Javascript wrapper and the like?

1 Like

To add to this question, does the Keyboard input rule apply to the Config or Live Config paths? For example, if I were to build a straw poll app, surely the broadcaster would need to enter text via a Keyboard at some point.

1 Like

The broadcaster enters text into the “config panel” not the video or panel.

Extensions may not use keyboard input to power functionality.

I interpret this to mean keyboard shortcuts, for example like the Kappa pet, you can’t use ctrl + t or y or u to make the pet do something.

You may still be allowed to use

<input type="text" />

As there are valid reasons for this such as “hey pick your Kappa pet name”

Adding on to what barry said. You can’t use keyboard event listeners like keydown, keyup, keypress or any event that captures input from the keyboard. HTML5 Input tag does not require these events.

Here is a thing about the HTML5 Gamepad API:

the pure API, without using any framework libraries, is not event/listener based.

The only two events that I can see are “gamepadconnected” and “gamepaddisconnected”, which only trigger in the event a controller is plugged into the system or removed. It could loosely be considered “user input”, since the user has to perform an action to do it, but the controller could also already be plugged in when the page/extension loads, which is why I say “loosely”.

Actually reading the GamePad is done via manually checking values, rather than asynchronous messages being sent. You dont listen for a “DOWN_BUTTON” event to trigger, but instead check the value of the GamePad’s ‘buttons’ array at regular intervals, usually on each run of requestAnimationFrame() to sync the animation/game logic to the users framerate.

I think the GamePad API would need official comment, since the API itself is in this weird gray area of “user input” and “manual checking of values”.

I think you misunderstood the docs. They said

Extensions may not use keyboard shortcuts to power functionality.

They mean hotkeys like ctrl + x, because twitch already uses hotkeys and they don’t want yours to conflict with theirs. Another part of the docs say

When a viewer clicks into an extension, Twitch sends focus back to the player, to ensure that keyboard shortcuts for the player continue to work. However, if an extension asks viewers to click on a form field element (for example, “field,” “select,” “textarea”), and the viewer does so, the focus stays on the form element.

You can use any inputs you like.

I can confirm that guanzo and Barry are correct - apologize for ambiguity in the docs.

1 Like