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?
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.
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.