Eliminar objeto seleccionado

En este ejemplo eliminamos el objeto seleccionado con el ratón al presionar la tecla del/supr:

for (var i = 0; i < 50; i++) {
    ce.rect(randint(width), randint(height), randint(25)+5)
    .attr({
        fill: randcolor(),
        velx: Math.random(),
        vely: Math.random(),
    });
}

ce.keydown("del", function(c, e){
    if (c.focused) {
        c.remove(c.focused);
        c.focused = null;
    }
}).draw();

Related Topics

This Page

Fork me on GitHub