explicitly consume enter press event

This commit is contained in:
DrMaxNix 2024-07-28 17:34:22 +02:00
parent c02e3dbab9
commit d55ff7c47c

View File

@ -6,7 +6,19 @@ window.addEventListener("load", function(event){
let copylink_button_list = document.getElementsByClassName("copylink");
for(let one_copylink_button of copylink_button_list){
// register onclick function
one_copylink_button.onclick = function(event){ copylink_click(this, event) };
one_copylink_button.onclick = function(event){
event.stopPropagation();
copylink_click(this);
};
// also allow enter press
one_copylink_button.onkeypress = function(event){
if(event.key === "Enter"){
event.preventDefault();
event.stopPropagation();
copylink_click(event.target);
}
};
// add descriptive title
one_copylink_button.title = copylink_hint_text;
@ -20,8 +32,7 @@ window.addEventListener("load", function(event){
*
* @param self Copylink button element.
*/
async function copylink_click(self, event){
event.stopPropagation();
async function copylink_click(self){
let success = true;
// RETRIEVE SECTION ID //