From 2e67ee4e1d183ab0782800734f48004ba2f398d6 Mon Sep 17 00:00:00 2001 From: Kieran Klukas Date: Wed, 23 Apr 2025 23:00:09 -0400 Subject: [PATCH] feat: allow using the enter key to add users --- bluesky-community-verifications.user.js | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/bluesky-community-verifications.user.js b/bluesky-community-verifications.user.js index 563ea09..dd47820 100644 --- a/bluesky-community-verifications.user.js +++ b/bluesky-community-verifications.user.js @@ -472,7 +472,6 @@ }); } }; - // Function to create the settings modal const createSettingsModal = () => { // Create modal container @@ -581,16 +580,29 @@ settingsModal.style.display = "none"; }); + // Function to add a user from the input field + const addUserFromInput = () => { + const input = document.getElementById("trustedUserInput"); + const handle = input.value.trim(); + if (handle) { + addTrustedUser(handle); + input.value = ""; + updateTrustedUsersList(); + } + }; + // Add trusted user button event document .getElementById("addTrustedUserBtn") - .addEventListener("click", () => { - const input = document.getElementById("trustedUserInput"); - const handle = input.value.trim(); - if (handle) { - addTrustedUser(handle); - input.value = ""; - updateTrustedUsersList(); + .addEventListener("click", addUserFromInput); + + // Add keydown event to input for Enter key + document + .getElementById("trustedUserInput") + .addEventListener("keydown", (e) => { + if (e.key === "Enter") { + e.preventDefault(); + addUserFromInput(); } }); -- 2.51.2