Currently, I am delving into the world of arrow functions and attempted to convert my code snippet below. Unfortunately, I have encountered a scope issue with funcCall and enterKey. My intuition tells me that utilizing an arrow function could potentially resolve this dilemma.
const pressKey = (funcCall, enterKey = 13) => {
document.addEventListener("keydown", _onKeyDown);
}
const _onKeyDown = (e) => {
if(e.keyCode === enterKey) {
e.preventDefault();
funcCall();
}
}