• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

KeyboardAPI

Status
Not open for further replies.
Level 21
Joined
Aug 3, 2004
Messages
710
JASS:
native TriggerRegisterKeyEvent	takes trigger whichTrigger, integer eventtype	returns nothing
native GetTriggerKey 		takes nothing 					returns integer
native SetKeyBlock 		takes integer i, boolean doBlock 		returns nothing
native ForceKeyDown		takes integer key				returns nothing
native ForceKeyUp		takes integer key				returns nothing
native ForceKeyType		takes integer key				returns nothing

// constants
constant integer EVENT_KEYUP = 0
constant integer EVENT_KEYDOWN = 1

Tutorial: N/A
Download: N/A
Native Set Type: Single Player or WarSoc
Release: 0.10
Other: N/A
 
Last edited by a moderator:
The only way to use this natives is installing RtC, right? Isn't there any other way to detect any key pressed and released than installing RtC?Unit abilities may detect some keys when pressed yet not when released, is JASS able to do such?

BTW I've been reading about the WarSoc Project and it just rules.:thumbs_up:
 
The only way to use this natives is installing RtC, right? Isn't there any other way to detect any key pressed and released than installing RtC?Unit abilities may detect some keys when pressed yet not when released, is JASS able to do such?

BTW I've been reading about the WarSoc Project and it just rules.:thumbs_up:
There's no way in regular wc3 to do what these native does, except for detecting arrow keys, and ofcourse the way with detecting abilities, which doesn't work very well.

Question: how fast are these compared to the regular keyboard press events?
I haven't done any speed tests, but since these work around some of warcraft III's safety things, i would guess this one is faster.
 
JASS:
library Test initializer Init
    private function Actions takes nothing returns nothing
        if(GetTriggerKey() == 87) then
            call BJDebugMsg("W was pressed")
        else
            call BJDebugMsg("Keycode " + I2S(GetTriggerKey()) + " was pressed")
        endif
    endfunction

    private function Init takes nothing returns nothing
     local trigger trig = CreateTrigger()
        call TriggerAddAction(trig, function Actions)
        call TriggerRegisterKeyEvent(trig, 1)
    endfunction
endlibrary
This is off the top of my head, since i'm at school atm. Basicly, call TriggerRegisterKeyEvent(trig, 1) detects when i press a key, and GetTriggerKey() returns what key it is, as an integer value.
 
Status
Not open for further replies.
Back
Top