Fix drumroll, pressed keys, pause menu, hide cursor
This commit is contained in:
@@ -2,8 +2,10 @@ class PageEvents{
|
||||
constructor(){
|
||||
this.allEvents = new Map()
|
||||
this.keyListeners = new Map()
|
||||
this.mouseListeners = new Map()
|
||||
this.add(window, "keydown", this.keyEvent.bind(this))
|
||||
this.add(window, "keyup", this.keyEvent.bind(this))
|
||||
this.add(window, "mousemove", this.mouseEvent.bind(this))
|
||||
}
|
||||
add(target, type, callback){
|
||||
this.remove(target, type)
|
||||
@@ -112,4 +114,17 @@ class PageEvents{
|
||||
})
|
||||
})
|
||||
}
|
||||
mouseEvent(event){
|
||||
this.lastMouse = event
|
||||
this.mouseListeners.forEach(callback => callback(event))
|
||||
}
|
||||
mouseAdd(target, callback){
|
||||
this.mouseListeners.set(target, callback)
|
||||
}
|
||||
mouseRemove(target){
|
||||
this.mouseListeners.delete(target)
|
||||
}
|
||||
getMouse(){
|
||||
return this.lastMouse
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user