JSFiddle - React, Tailwind, and code Playground
Example of an extension event firing on clicks and enter keypresses
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dijit/themes/claro/document.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dijit/themes/claro/claro.css">
<div id="test" tabindex="0">test</div>
CSS
#test {
border: 1px dotted #999;
margin: 1em;
padding: 0.5em;
}
#test:focus {
border-color: #333;
}
JavaScript
require([
"dojo/on",
"dojo/domReady!"
], function(on){
function clickOrEnter(node, listener) {
return on(node, "click,keyup", function(evt) {
if (evt.keyCode === 13 || !evt.keyCode) {
listener.call(this, evt);
}
});
}
on(document.getElementById("test"), clickOrEnter, function(evt) {
console.log(evt);
});
});