Начинающий-Js-кодер,
нажать ctrl+m+y
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
div.hot{
width: 100px;
height: 100px;
border: 1px dashed Gray;
padding: 5px;
}
.Red{
background-color: Red;
}
.Green{
background-color: Green;
}
.Yellow{
background-color: Yellow;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.2/mousetrap.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var arrayhotkey = {
"ctrl+m+y": function(event) {
event.preventDefault();
alert("my")
},
"ctrl+b": function(event) {
event.preventDefault();
alert("b")
}
};
var keys = "ctrl+m+y";
Mousetrap(document).bind(keys, arrayhotkey[keys])
});
</script>
</head>
<body>
<div class="hot Red"></div>
</body>
</html>