--- title: "typeToSearch Methods" slug: "typetosearch-methods" updated: 2024-05-29T15:59:04Z published: 2024-05-29T15:59:04Z canonical: "docs.xgen.ai/typetosearch-methods" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.xgen.ai/llms.txt > Use this file to discover all available pages before exploring further. # typeToSearch Methods The `typeToSearch` methods are used to control the type-to-search behavior. #### typeToSearch.search() Used to trigger a type-to-search query. This query will still respect the debounce and response timeout settings as defined in the `getTypeToSearch` options. Note: this function is called automatically on key press if bound to an input. Parameters passed to the `search` method: | NAME/TYPE | DESCRIPTION | | --- | --- | | `query` string | The search term that will be used to find relevant products. | | `options` TypeToSearchSearchOptions | The options that will control the behavior of the type-to-search query. | #### typeToSearch.search() Options The type-to-search `search` method accepts the following options: | NAME/TYPE | DESCRIPTION | | --- | --- | | `context` object | An object containing the contextual variables used for filters. Note: this context will be combined with the context used in the context property above | | `key` string | Note: for XGen rendered deployments only. The most recent key that was pressed on the keyboard. Used for tts activation settings. | #### typeToSearch.bindInput() Used to bind an HTML Input element to the type-to-search object. Any character the users types within that element will fire the `search` method above on the set debounce. Parameters passed to the `bindInput` method: | NAME/TYPE | DESCRIPTION | | --- | --- | | `input` HTMLInputElement | The HTML Input element that will be listened to for the user typing. | #### Example Binding a search input: ```javascript // Start a type to search session const tts = getTypeToSearch(console.log, { deploymentId: '3d8e3aa4-b1e9-4b1b-9ff6-ca4bc64806d0' }); // Grab the input from the DOM const inputElement = document.querySelector('input.searchInput'); // Bind the search input tts.bindInput(inputElement); ```