---
title: "Detect user input in PDF form using JavaScript | Nutrient"
canonical_url: "https://www.nutrient.io/guides/web/forms/fill-form-fields/detect-user-input/"
md_url: "https://www.nutrient.io/guides/web/forms/fill-form-fields/detect-user-input.md"
last_updated: "2026-05-22T19:52:09.654Z"
description: "Learn how to effectively detect user input in web forms with our step-by-step guide. Enhance user experience and optimize form functionality today!"
---

# Detecting user inputs in PDF forms

You can programmatically trigger actions synchronized with user input in document form fields. You only need to subscribe to the corresponding UI event using [`instance#addEventListener`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#addEventListener), and the callback you provide will be called whenever the event takes place:

```js

instance.addEventListener("annotations.focus", function (annotationFocusEvent) {
	// Will log the properties of the widget annotation that was just focused.
	console.log(annotationFocusEvent.annotation.toJS());
});

```

Other events that can be used to detect user input in form fields besides [`"annotations.focus"`](https://www.nutrient.io/api/web/NutrientViewer.AnnotationsFocusEvent.html) are [`"annotations.blur"`](https://www.nutrient.io/api/web/NutrientViewer.AnnotationsBlurEvent.html) and [`"annotations.press"`](https://www.nutrient.io/api/web/NutrientViewer.AnnotationsPressEvent.html).

For a complete list of events available for subscription, you can check out the API documentation entry for [`instance#addEventListener`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#addEventListener).
---

## Related pages

- [Adding an image to a PDF form using JavaScript](/guides/web/forms/fill-form-fields/add-image.md)
- [Attach a file to a PDF form using JavaScript](/guides/web/forms/fill-form-fields/attach-a-file.md)
- [Dynamic font loading in PDF forms using Nutrient Web SDK](/guides/web/forms/fill-form-fields/dynamic-font-loading.md)
- [Headless form fill](/guides/web/forms/fill-form-fields/headless.md)
- [Import data into PDFs from a database](/guides/web/forms/fill-form-fields/import-from-database.md)
- [Import data into PDF forms using Instant JSON](/guides/web/forms/fill-form-fields/import-from-instant-json.md)
- [Fill PDF form fields using our JavaScript viewer UI](/guides/web/forms/fill-form-fields/using-the-ui.md)
- [Import data into PDF form using Web SDK with Document Engine](/guides/web/forms/fill-form-fields/import-from-server-backed.md)
- [Import data into PDF forms using XFDF](/guides/web/forms/fill-form-fields/import-from-xfdf.md)
- [Customizing PDF form permissions](/guides/web/forms/fill-form-fields/permissions.md)
- [Fill PDF forms programmatically using JavaScript](/guides/web/forms/form-filling.md)

