I am following the below js fiddle. I am perfectly running it. https://jsfiddle.net/Jonah/sbtoukan/1/ But in the above link the text is cleared when I click on the text. I want to clear the text only when I press the delete key. I tried several ways. But nothing working for me. Below is the exact code which is only allowing me to clear the text after clicking on the text.
var canvas = new fabric.Canvas('container');
var oText = new fabric.IText('Tap and Type', {
left: 0,
top: 0,
fontFamily: 'Bree Serif',
fontSize: 22,
cache: false
});
canvas.on("text:editing:entered", clearText);
function clearText(e) {
if (e.target.type === "i-text") {
if (e.target.text === "Tap and Type") {
e.target.text = "";
canvas.renderAll();
};
}
}
canvas.add(oText);