I always use this for my keydowns, don't ask why.
NPC Code:
if (created) {
setarray this.keydown,10;
setarray this.oldkeydown,10;
}
if (playerenters||timeout) {
for (this.k=0;this.k<10;this.k++) this.oldkeydown[this.k]=this.keydown[this.k];
for (this.k=0;this.k<10;this.k++) this.keydown[this.k]=(keydown(this.k));
timeout=0.05;
}