Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Keydown event? (Not onKeyPressed) (https://forums.graalonline.com/forums/showthread.php?t=73066)

DrakilorP2P 03-25-2007 11:12 PM

Keydown event? (Not onKeyPressed)
 
I'm trying to find a way to detect when a key is pushed down, and not when it's pressed (onKeyPressed). The effect would basically be the same as onKeyPressed, but without the auto-repeat most operating systems implements.

From searching the forums, I've found that onKeyDown and onKeyUp apparently can be used in GUI controls, but none of them works in a standard "weapon". (Declaring onKeyUp() and KeyUp())

My goal is to call a function when a key is tapped twice within a specified timespan. At first I did this with onKeyPressed and timevar2, but previously mentioned auto-repeat messed that up, calling the function repeatedly when the button was held down.

As an alternative, I thought about checking for the keys in onTimeout(), but the way I constructed it, it would limit the timespan to a minimum of 0.1. (Not allowing the player to double press faster than that)

Angel_Light 03-25-2007 11:41 PM

OnKeyDown works with only like 10 buttons if I remember correctly, though maybe I'm wrong :/

keydown( key ) the specified key is pressed
(0..10:up,left,down,right,S,A,D,M,tab,Q,P)

DrakilorP2P 03-26-2007 12:06 AM

Quote:

Originally Posted by Angel_Light (Post 1293054)
OnKeyDown works with only like 10 buttons if I remember correctly, though maybe I'm wrong :/

keydown( key ) the specified key is pressed
(0..10:up,left,down,right,S,A,D,M,tab,Q,P)

You don't happen to be familiar with a way to to use keydown() in the way specified? (A better way than limiting to a minimum of 0.1 seconds)

zokemon 03-26-2007 12:50 AM

0.1 seconds is pretty damn fast... Keep it like you have it and you should be just fine.

(And it isn't really 0.1...it is actually >0.05 since they just have to have the key released by the next 0.05 timeframe...after that frame they can press it again even if it is at 0.06 seconds)


All times are GMT +2. The time now is 05:42 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.