Keyboard/Mouse api?
drewhamlett opened this issue · comments
I'm trying to wrap my head around it the event api, more specifically keyboard/mouse. Is there an example you can give me real quick. Doesn't have to be detailed. Thanks.
https://github.com/meh/shekels/blob/master/app/component/input.rb this should help.
Oh gotcha. So it's attached to the $window object by default. So keybaord stuff is like
$window.on('keydown') do |e|
$console.log(e.code)
end
I don't know what I was trying to do before. Haha
In that source I'm using a framework that deals with deferring the events to a rendered element.
But even handling semantics work like in JavaScript, if you want to catch all keydowns on the whole page, you should indeed observe the event on the window/document.
Yea that's where I was hung up at. I've been looking over the source for a while. I thought I had to instantiate some kind of Keyboard object. Didn't know it was attached to the $window/$document variable.
Yeah, there's no Keyboard or Mouse abstraction, but I don't see why there shouldn't be in the future. For now you'll just have to deal with the standard event handling the browser provides.