1

I am trying to implement the following code in order to remove the text from the canvas. Although it is perfectly working. But my question is that it implements when i click on the text. I want that it should implement when i press the delete key or a delete html button. That is why i am trying to understand that what is 'e' in the clearText function. Below is the reference code which is currently i am considering to remove my text from canvas.

function clearText(e) {
if (e.target.type === "i-text") {
if (e.target.text === textarea) {
e.target.text = "";
canvas.renderAll();
};
}
}
hirazzz
  • 49
  • 2
  • 8
  • The `e` is an event object, which contains infomation about the event – Mikkel Jan 30 '20 at 05:30
  • Respected sir, Can we modify the e object ?can we place specific keycode in clearText parameter instead of using e? – hirazzz Jan 30 '20 at 05:32
  • What is "specific keycode" ? Like a keyboard character? – Mikkel Jan 30 '20 at 05:35
  • @HiraZahid you can use `e.key` to get the pressed key and `e.keyCode` will give you the key pressed. just log the event like `console.log(e);` – Jai Jan 30 '20 at 05:42
  • sir specific keycode for enter key is 13. so i will write function clearText(e.13)??? – hirazzz Jan 30 '20 at 05:48

1 Answers1

0

The "e" refers to the event object which is used to work with event-related functionalities. Below link will provide you more information about that. "Target" is a property of that event object.

https://www.w3schools.com/jsref/dom_obj_event.asp