1
SCI Syntax Help / Re: Capturing Keystrokes misses the arrow keys
« on: December 20, 2025, 06:45:25 PM »
So it turns out, the arrow keys and the number pad keys are not a part of the key handler, but the direction handler... and maps to event type 68... anyway, here is what worked.
I created an egoHandleEvent Script and then set any old random view to use it when the time came. I left the joystick event in there, but I don't have a joystick so I don't know if that actually works, but the arrow key presses are now captured. In my case, I am setting a couple of variables, pressed tells the doit method that they have pressed an arrow key and to pick the next direction, while the entered variable tells me what direction they pressed as it corresponds to a views loops
I created an egoHandleEvent Script and then set any old random view to use it when the time came. I left the joystick event in there, but I don't have a joystick so I don't know if that actually works, but the arrow key presses are now captured. In my case, I am setting a couple of variables, pressed tells the doit method that they have pressed an arrow key and to pick the next direction, while the entered variable tells me what direction they pressed as it corresponds to a views loops
Code: [Select]
(instance egoHandleEvent of Script
(properties)
(method (init)
(super init: &rest)
(gOldDH addToFront: self)
)
(method (dispose)
(gOldDH delete: self)
(super dispose:)
)
(method (handleEvent pEvent)
; (Printf "Event Type: %d" (pEvent type?))
; (Printf "Event Message Type: %d" (pEvent message?))
(switch (pEvent type?)
(evJOYSTICK
(switch (pEvent message?)
(JOY_RIGHT (= pressed 1)(= entered 1))
(JOY_LEFT (= pressed 1)(= entered 2))
(JOY_UP (= pressed 1) (= entered 4))
(JOY_DOWN (= pressed 1)(= entered 3))
)
(pEvent claimed: 1)
)
(68
(switch (pEvent message?)
(1 (= pressed 1) (= entered 4)); pressed Up...
(7 (= pressed 1) (= entered 2)); pressed left
(3 (= pressed 1) (= entered 1)); pressed right
(5 (= pressed 1) (= entered 3)); pressed down
)
(pEvent claimed: 1)
)
(else
(pEvent claimed: 1)
)
)
(super handleEvent: pEvent)
) ; ends method
)