Skip to content

Instantly share code, notes, and snippets.

@kntmr
Last active March 12, 2021 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kntmr/d34a086fc87fb89105428b7e64f38144 to your computer and use it in GitHub Desktop.
Save kntmr/d34a086fc87fb89105428b7e64f38144 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.lock {
overflow: hidden;
}
.overlay {
z-index: 98;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.75);
}
</style>
<script>
const onClick = () => {
const body = document.querySelector('body')
body.classList.add('lock')
if (!body.querySelector('.overlay')) {
const overlay = document.createElement('div')
overlay.classList.add('overlay')
body.appendChild(overlay)
}
console.log(`submit!`)
}
</script>
</head>
<body>
<button onclick="onClick()">Submit</button>
<script>
const cancelKeyEvent = (event) => {
if (event.target.tagName !== 'BUTTON') {
return true
}
if (event.detail !== 0) {
return true
}
if (event.pointerType === 'mouse') {
return true
}
console.warn(`cancelKeyEvent!`)
event.stopPropagation()
}
//window.addEventListener('click', cancelKeyEvent, true)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment