fix Standalone mode can't be triggered via keyboard #11

This commit is contained in:
Tiago
2025-04-22 09:49:53 +01:00
parent 73406d6568
commit b16ae18264
4 changed files with 14 additions and 4 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@cap.js/widget",
"version": "0.0.20",
"version": "0.0.21",
"description": "Client-side widget for Cap. Cap is a lightweight, modern open-source CAPTCHA alternative designed using SHA-256 PoW.",
"keywords": [
"account security",
+11 -1
View File
@@ -123,7 +123,7 @@
const apiEndpoint = this.getAttribute("data-cap-api-endpoint");
if (!apiEndpoint) throw new Error("Missing API endpoint");
const { challenge, target, token } = await (
const { challenge, token } = await (
await fetch(`${apiEndpoint}challenge`, {
method: "POST",
})
@@ -255,6 +255,16 @@
if (!this.#div.hasAttribute("disabled")) this.solve();
});
this.#div.addEventListener("keydown", (e) => {
if (
(e.key === "Enter" || e.key === " ") &&
!this.#div.hasAttribute("disabled")
) {
e.preventDefault();
this.solve();
}
});
this.addEventListener("progress", this.boundHandleProgress);
this.addEventListener("solve", this.boundHandleSolve);
this.addEventListener("error", this.boundHandleError);