useInput

Hook for accessing input events from the Roku runtime

import { useInput } from "@roku-sdk/runtime/input";
const useInput: () => { inputParams: Accessor<InputParams | null>; voiceInputParams: Accessor<VoiceInputParams | null> } & { updateVoiceInputStatus: (params: { id: number; status: VoiceHandledStatus }) => boolean }

Description

Hook for accessing input events from the Roku runtime.

Provides reactive access to both standard input events and voice input events. The hook automatically sets up input handlers when the component mounts and cleans them up when it unmounts.

Example

// Basic usage
const input = useInput();

createEffect(() => {
    const params = input.inputParams();
    if (params) {
        console.log('Input received:', JSON.stringify(params));
    }
});
// Listen to voice input
const input = useInput();

createEffect(() => {
    const voiceParams = input.voiceInputParams();
    if (voiceParams) {
        console.log('Voice transcription:', JSON.stringify(voiceParams));
    }
});

What’s Next

Did this page help you?