User:Lionel.rowe/inline-audio.js

let playing

document.body.addEventListener('click', (e) => {	const src = e.target		.closest('.haudio')		?.querySelector('[href*="//upload.wikimedia.org"]')		?.href	if (src) {		playing?.pause	}

if (src && !e.ctrlKey) { e.preventDefault

playing = new Audio(src) playing.play } })

window.addEventListener('keydown', (e) => {	if (e.key === 'Escape') {		playing?.pause	} })