HTML5 Canvas Remove Event Listener by Name with Konva

To remove an event listener by name with Konva,
we can namespace the event type with the on() method so that we can later
remove the event listener by the same namespace with the off() method.

Instructions: Click on the circle to see two alerts triggered from two different
onclick event bindings. Remove the event listeners using the buttons to
the left, and again click on the circle to observe the new onclick bindings.

Konva Remove By Name Demoview raw
<!DOCTYPE html>
<script src=""></script>
<meta charset="utf-8">
<title>Konva Remove Event Listener by Name Demo</title>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #F0F0F0;
#buttons {
position: absolute;
top: 5px;
left: 10px;
<div id="container"></div>
<div id="buttons">
<button id="remove1">
Remove First Listener
<button id="remove2">
Remove Second Listener
<button id="removeAll">
Remove All Listeners
function writeMessage(message) {
var stage = new Konva.Stage({
container: 'container',
width: 300,
height: 300
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2 + 10,
radius: 70,
fill: 'red',
stroke: 'black',
strokeWidth: 4
circle.on('click.event1', function() {
alert('First Listener');
circle.on('click.event2', function() {
alert('Second Listener');
document.getElementById('remove1').addEventListener('click', function() {'click.event1');
alert('First onclick removed');
}, false);
document.getElementById('remove2').addEventListener('click', function() {'click.event2');
alert('Second onclick removed');
}, false);
document.getElementById('removeAll').addEventListener('click', function() {'click');
alert('All onclicks removed');
}, false);