Professional Documents
Culture Documents
Haxball Avatar Hotkey
Haxball Avatar Hotkey
Haxball Avatar Hotkey
(function() {
"use strict";
// SET DURATION FOR AVATAR TO APPEAR
var defaultDuration = 800;
// SET DEFAULT AVATAR & change emojis - can be extended
// and changed by following the same syntax.
var avatars = {
'default': "🤠",
'w': "👏",
'a': "👋",
's': "👀",
'd': "🤬",
'x': "😨"
}
function process(key) {
var avatar = avatars[key];
var duration = defaultDuration;
if (avatar) {
setAvatar(avatar);
if (reset != undefined) {
clearTimeout(reset);
}
reset = setTimeout(function() {
setAvatar(avatars['default']);
}, duration);
}
}
var reset;
//document.activeElement
var iframe;
setTimeout(function() {
iframe = document.querySelector("iframe").contentWindow.document;
iframe.body.addEventListener("keydown", listener, true);
console.log("Setup complete");
}, 3000);
})();