Skip to content

Commit ea8cb99

Browse files
Merge pull request #26 from tapiwamakandigona/fix/email-shortcut-referenceerror
Fix: E keyboard shortcut throws ReferenceError (EMAIL/emailLink undefined)
2 parents 25063cd + 80e14c6 commit ea8cb99

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

script.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ document.addEventListener('keydown', e => {
2323
window.open('https://github.com/tapiwamakandigona', '_blank', 'noopener');
2424
}
2525
if (e.key === 'e' || e.key === 'E') {
26-
navigator.clipboard && navigator.clipboard.writeText(EMAIL).then(() => {
27-
if (emailLink) {
28-
const orig = emailLink.textContent;
29-
emailLink.textContent = 'Copied ✓';
30-
setTimeout(() => { emailLink.textContent = orig; }, 1800);
31-
}
32-
});
26+
const EMAIL = 'silentics.org@gmail.com';
27+
const emailLink = document.querySelector('a[href^="mailto:"]');
28+
if (navigator.clipboard) {
29+
navigator.clipboard.writeText(EMAIL).then(() => {
30+
if (emailLink) {
31+
const orig = emailLink.textContent;
32+
emailLink.textContent = 'Copied ✓';
33+
setTimeout(() => { emailLink.textContent = orig; }, 1800);
34+
}
35+
}).catch(() => {});
36+
}
3337
}
3438
});

0 commit comments

Comments
 (0)