Skip to content

Instantly share code, notes, and snippets.

@DKunin
Last active December 17, 2015 06:08
Show Gist options
  • Save DKunin/5562788 to your computer and use it in GitHub Desktop.
Save DKunin/5562788 to your computer and use it in GitHub Desktop.
Arrows and wheels capture for some stuff on the page
$(document).on('keydown',function(e){
document.passTime = setTimeout(function(){passMatch=""},2000);
var passWord = 'IDDQD';
var keys = {
73:"I",
68:"D",
81:"Q"
};
if(e.keyCode===73||e.keyCode===68||e.keyCode===81||e.keyCode===40){
passMatch+= keys[e.keyCode];
}
if(passMatch===passWord) {
adjustStuff();
};
if(passWord.indexOf(passMatch)===-1) {
passMatch = "";
}
})
function adjustStuff(){
$(document).on('keydown',function(e){
var curRegion = $('.map-navigation-wrapper .map-navigation-item.active');
var curRegionId = curRegion.data().id;
var curObj = _.find(regionsData,function(o){return o.id===parseInt(curRegionId)})
if(e.keyCode===13) {
console.log(startingData);
}
if(e.keyCode===37||e.keyCode===38||e.keyCode===39||e.keyCode===40){
if(e.keyCode===37) {
curObj.offsetLeft--;
}
if(e.keyCode===39) {
curObj.offsetLeft++;
}
if(e.keyCode===38) {
curObj.offsetTop--;
}
if(e.keyCode===40) {
curObj.offsetTop++;
}
}
if(e.keyCode===107||e.keyCode===109){
if(e.keyCode===107) {
curObj.scale = curObj.scale+0.01;
}
if(e.keyCode===109) {
curObj.scale = curObj.scale-0.01;
}
}
if(e.keyCode===37||e.keyCode===38||e.keyCode===39||e.keyCode===40||e.keyCode===107||e.keyCode===109){
curRegion.find('.info').click()
console.log(curObj);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment