Detect Backspace pressionado EventListener
document.addEventListener("keydown", function(event)
{
if (event.key == "c")
{
console.log("C Pressed");
document.getElementById("btnConvert").click();
}
var convertButton = document.getElementById("btnConvert");
if (event.key == "Backspace")
{
console.log("Backspace Pressed");
var textboxContent = document.getElementById("txtFahrenheit").value;
if (textboxContent.value == "" || textboxContent.value == "-")
{
convertButton.disabled = true;
}
}
})
/*HTML:
<button id="btnConvert">Convert</button>
<input id="txtFahrenheit" type="text" autofocus />
*/
Meandering Meerkat