Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hook for keyboard down or when user start typing #619

Open
cddodev opened this issue Dec 11, 2023 · 1 comment
Open

hook for keyboard down or when user start typing #619

cddodev opened this issue Dec 11, 2023 · 1 comment

Comments

@cddodev
Copy link

cddodev commented Dec 11, 2023

Hi,

I am not sure if there is a hook here where I can track when user starts typing?

I have tried the following but doesnt work...

  const element = document.querySelector("#my-autocomplete-container");
  const id = "app-site-search__input";
  accessibleAutocomplete({
    element: element,
    id: id,
    confirmOnBlur: false,
    autoselect: true,
    source: customSuggest,
    templates: {
      inputValue: inputValueTemplate,
      suggestion: suggestionTemplate,
    },
  });
  // attach event listener
  let input_field = document.getElementById(id);
  // generate a debounced version with a min time between calls of 1.5 seconds
  let searchTerm = function () {
    console.log('searched'+ input_field.value)
  };
  input_field.addEventListener("input", searchTerm);

onConfirm only gets fired when user presses enter which is not what I want.

@akselander
Copy link

@cddodev you can most likely add this hook as another side effect to the source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants