const hitNotesSet = new WeakSet(); const tolerance = 10; // hassasiyet
const arrowMap = { ‘←’: document.querySelector(‘.arrows-container .arrow-key:nth-child(1)’), ‘↓’: document.querySelector(‘.arrows-container .arrow-key:nth-child(2)’), ‘↑’: document.querySelector(‘.arrows-container .arrow-key:nth-child(3)’), ‘→’: document.querySelector(‘.arrows-container .arrow-key:nth-child(4)’) };
const keyMap = { ‘↑’: ‘ArrowUp’, ‘↓’: ‘ArrowDown’, ‘←’: ‘ArrowLeft’, ‘→’: ‘ArrowRight’ };
function hitNotes() { document.querySelectorAll(‘.note’).forEach(note => { if (hitNotesSet.has(note)) return;
const arrow = note.innerText.trim();
const target = arrowMap[arrow];
if (!target) return;
const noteRect = note.getBoundingClientRect();
const targetRect = target.getBoundingClientRect();
const noteY = noteRect.top + noteRect.height / 2;
const targetY = targetRect.top + targetRect.height / 2;
if (Math.abs(noteY - targetY) <= tolerance) {
const key = keyMap[arrow];
if (key) {
console.log(`Basıldı: ${arrow} (${key})`);
document.dispatchEvent(new KeyboardEvent('keydown', { key }));
document.dispatchEvent(new KeyboardEvent('keyup', { key }));
hitNotesSet.add(note);
}
}
});
}
setInterval(hitNotes, 10);