My App will allow people to write in a canvas, so I have attached a event listener to the keypress key, this fires the following function:
var Keypress = function(event) {
if (event.keyCode == 8) {
chatRoom.removeLetter();
event.preventDefault();
}
if(event.keyCode == 13){
chatRoom.newLine();
}
chatRoom.addText(event.charCode,"White");
}
the issue is this, currently if someone hits backspace 1 character can get deleted then, backspace gets frozen and can not be used again until another key is pressed. However is what I am looking for is for backspace to be able to be hit many times, many characters get deleted and no one ends up going back a page.
In essense I am trying to find a way for the function to fire the removeLetter() event and just disable going back on the browser, However all examples I have seen ever freeze up the backspace (leading to this one letter can be deleted) or do not work (return false would just not work at all for me).
The problem is that you’re writing the backspace ‘character’ to you chatroom. Thus, when you press backspace the second time, you’re just deleting that backspace character, and then rewriting it.
Try returning after removing your letter: