JSFiddle - React, Tailwind, and code Playground
HTML
mouse<b>move</b> here...
<div id="whichkey"></div>
<p id="log"></p>
CSS
#whichkey {
height: 50vh;
background: gold;
}
JavaScript
var pressedLog = $('#log');
$('#whichkey').bind('mousemove', function(e) {
pressedLog.html('Pressed:<ul>' +
'<li>e.buttons: ' + e.buttons +
'</li><li>e.which: ' + e.which +
'</li></ul>');
//Fade out when the mouse stops moving:
//http://stackoverflow.com/a/1421338/1869660
pressedLog.stop(true).css({opacity:'1'}).show();
pressedLog.fadeOut();
});
/* Note:
e.which is always 1 in IE/Firefox:
https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which#Browser_compatibility
https://bugzilla.mozilla.org/show_bug.cgi?id=1048294
*/