# Callbacks

Address Finder also provides callbacks which let you hook the following events:

## Address Fields Populated[​](#address-fields-populated "Direct link to Address Fields Populated")

[`onAddressPopulated`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onAddressPopulated)

Invoked after the selected address is applied to input fields.

## Full Address Retrieved from API[​](#full-address-retrieved-from-api "Direct link to Full Address Retrieved from API")

[`onAddressRetrieved`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onAddressRetrieved)

Invoked when the Address Finder client has retrieved a full address from the API following a user accepting a suggestion. The first argument is an object representing the address that has been retrieved.

## User Selects an Address Selection[​](#user-selects-an-address-selection "Direct link to User Selects an Address Selection")

[`onAddressSelected`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onAddressSelected)

Invoked immediately after the user has selected a suggestion (either by click or keypress). The first argument is an object which represents the suggestion selected.

## Address Finder field is De-Focused[​](#address-finder-field-is-de-focused "Direct link to Address Finder field is De-Focused")

[`onBlur`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onBlur)

Invoked when the user unfocuses from the address input field.

## Address Suggestion List Closes[​](#address-suggestion-list-closes "Direct link to Address Suggestion List Closes")

[`onClose`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onClose)

Invoked when Address Finder suggestion box is closed (i.e. hidden from user).

## API Key Check Fails[​](#api-key-check-fails "Direct link to API Key Check Fails")

[`onFailedCheck`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onFailedCheck)

Invoked if checkKey is enabled and the check fails.

## Address Field is Selected[​](#address-field-is-selected "Direct link to Address Field is Selected")

[`onFocus`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onFocus)

Invoked when user selects or focuses address input field.

## User inputs into Address Finder Field[​](#user-inputs-into-address-finder-field "Direct link to User inputs into Address Finder Field")

[`onInput`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onInput)

Invoked when user edits Address Finder field.

## User Presses a Key[​](#user-presses-a-key "Direct link to User Presses a Key")

[`onKeyDown`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onKeyDown)

Invoked when keypress is triggered on input.

## Address Finder Successfully Loads[​](#address-finder-successfully-loads "Direct link to Address Finder Successfully Loads")

[`onLoaded`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onLoaded)

Invoked when Address Finder has been successfully attached to the input element.

## Address Finder is Mounted to DOM[​](#address-finder-is-mounted-to-dom "Direct link to Address Finder is Mounted to DOM")

[`onMounted`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onMounted)

Invoked when controller attaches to the DOM (controller.view\.attach()).

## User Clicks on Suggestion List[​](#user-clicks-on-suggestion-list "Direct link to User Clicks on Suggestion List")

[`onMouseDown`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onMouseDown)

Invoked when mousedown event is triggered on suggestion list.

## Address Suggestion List Opens[​](#address-suggestion-list-opens "Direct link to Address Suggestion List Opens")

[`onOpen`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onOpen)

Invoked when Address Finder suggestion box is opened (i.e. presented to the user).

## Address Finder Detaches from DOM[​](#address-finder-detaches-from-dom "Direct link to Address Finder Detaches from DOM")

[`onRemove`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onRemove)

Invoked when controller detaches from the DOM (controller.view\.detach()).

## Full Address Retrieval Fails[​](#full-address-retrieval-fails "Direct link to Full Address Retrieval Fails")

[`onSearchError`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onSearchError)

Invoked when an error has occurred following an attempt to retrieve a full address. In this scenario the user will also receive a message to manually input their address.

The first argument is an error instance (i.e. inherits from Error) representing the error which has occurred.

Examples of errors includes "lookup balance exhausted" and "lookup limit reached" errors.

## Address Suggestion is Selected[​](#address-suggestion-is-selected "Direct link to Address Suggestion is Selected")

[`onSelect`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onSelect)

Invoked when a suggestion has been selected.

## Address Suggestion Retrieval Fails[​](#address-suggestion-retrieval-fails "Direct link to Address Suggestion Retrieval Fails")

[`onSuggestionError`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onSuggestionError)

Invoked when an error has occurred following an attempt to retrieve suggestions for a key press. In this scenario the user will also receive a message to manually input their address.

The first argument is an error instance (i.e. inherits from Error) representing the error which has occurred.

Examples of errors includes "lookup balance exhausted" and "lookup limit reached" errors.

## Address Suggestions Retrieved from API[​](#address-suggestions-retrieved-from-api "Direct link to Address Suggestions Retrieved from API")

[`onSuggestionsRetrieved`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onSuggestionsRetrieved)

Invoked immediately after address suggestions are retrieved from the API. The first argument is an array of address suggestions.

## Hidden Address Fields are Unhidden[​](#hidden-address-fields-are-unhidden "Direct link to Hidden Address Fields are Unhidden")

[`onUnhide`](https://address-finder.ideal-postcodes.co.uk/interfaces/Controller.ControllerOptions.html#onUnhide)

Invoked when hidden fields are unhidden (i.e. user selects an address or opts for manual input)
