Skip to content

Widget Events

The powCAPTCHA widget emits various events that you can listen to in order to handle user interactions and widget state changes. This allows you to customize the behavior of the widget based on user actions.

The following events are available for the powCAPTCHA widget:

Event NameDescription
@powcaptcha/widget/solvedFired when the challenge is successfully solved. Contains a token in the event detail.
@powcaptcha/widget/errorFired when an error occurs during the challenge process. Contains error details in the event detail.
@powcaptcha/widget/solvingFired when the challenge solving process starts. No additional detail is provided.
@powcaptcha/widget/solving/progressFired to indicate progress while solving the challenge. Contains a progress value in the event detail.

You can listen to these events using standard JavaScript event listeners. Here’s an example of how to do this:

const widget = document.querySelector('powcaptcha-widget');
widget.addEventListener('@powcaptcha/widget/solved', (event) => {
console.log('Challenge solved:', event.detail.token);
});
widget.addEventListener('@powcaptcha/widget/error', (event) => {
console.error('Error occurred:', event.detail.error);
});
widget.addEventListener('@powcaptcha/widget/solving', () => {
console.log('Solving challenge...');
});
widget.addEventListener('@powcaptcha/widget/solving/progress', (event) => {
console.log('Solving progress:', event.detail.progress);
});
Contribute

What’s on your mind?

Create GitHub Issue

Quickest way to alert our team of a problem.