Skip to content

Instantly share code, notes, and snippets.

@vjk2005
Created May 16, 2018 17:05
Show Gist options
  • Save vjk2005/71f4dfc1e9892a65cc656b660cf28e90 to your computer and use it in GitHub Desktop.
Save vjk2005/71f4dfc1e9892a65cc656b660cf28e90 to your computer and use it in GitHub Desktop.
Dynamically zoom-in on keypress to make close-quarters fighting easier on Airmash. Also adds a shortcut key for flag drops.
// press option key to zoom-in for close-quarters fighting
let zoom = false
document.onkeydown = e => {
if(e.key == 'Alt') {
zoom = true
e.stopPropagation()
e.preventDefault()
config.scalingFactor = 2000
Graphics.resizeRenderer(window.innerWidth, window.innerHeight)
return false
}
// press y to drop
if(e.key == 'y') UI.parseCommand('/drop')
}
document.onkeyup = e => {
if(zoom && !e.altKey) {
config.scalingFactor = 5000
Graphics.resizeRenderer(window.innerWidth, window.innerHeight)
zoom = false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment