using key presses to call a function
Hi, i am trying to get the "enter" key press to call the same function as my button click for a textinput component in animate (canvas), but it seems to not want to work with anything that uses a "this", only with elements that are actually part of the DOM that are referenced with getElementById.
I have this code here for the eventlistener and the function:
window.addEventListener("keydown", keyPressed.bind(this));
function keyPressed(evt) {
var k = evt.key.toLowerCase();
if (k=="enter") {
document.getElementById("inputBox").value = "";
this.chatRecord.text = "test";
}
}
it works fine with setting the inputBox to blank, but will not do anything with the chatRecord called using "this".
what am i doing wrong? can someone please help, thanks!
