Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,30 @@ $(document).on("keydown keyup", function(e) {
$.play(instrument, key, e.type === "keydown");
}
});
$.note = function(key, delay = 50) {
setTimeout(() => {
var e = jQuery.Event("keydown");
e.key = key;
$(document).trigger(e);
setTimeout(() => {
var e = jQuery.Event("keyup");
e.key = key;
$(document).trigger(e);
}, delay);
Comment on lines +258 to +262
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange indentions here

}, delay);
};

$.song = function(mySong) {
let length = 0;
mySong.forEach(function(s) {
const data = s.split(':');
length += parseInt(data[1]);
setTimeout(() => {
$.note(data[0].toString(), 80);
}, length)
});
};

$(document).on("touchstart touchend", function(e) {
if (e.target.classList.contains("layer")) {
if (e.type === "touchstart") {
Expand Down