Skip to content

Commit

Permalink
Added functionality to copy the passwword
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanKHawkins committed Jan 22, 2025
1 parent d44fda1 commit 58ef0ee
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ lengthSelector.addEventListener("input", (e) => {
});

lengthSelector.addEventListener("change", generatePassword);
passwordDisplay.addEventListener("click", copyPassword);

function clampValues(val, min, max) {
if (val < min) {
Expand Down Expand Up @@ -90,3 +91,10 @@ function generatePassword() {
function getRandomInRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

function copyPassword() {
let password = passwordDisplay.innerText;
navigator.clipboard.writeText(password);
displayPassword("copied...");
setTimeout(() => {displayPassword(password)}, 250);
}

0 comments on commit 58ef0ee

Please sign in to comment.