• 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.

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:

Gox

Gox

Level 2
Joined
Dec 10, 2007
Messages
6
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:
 
Level 21
Joined
Aug 3, 2004
Messages
710
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.
 
Level 21
Joined
Aug 3, 2004
Messages
710
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.
 
Level 7
Joined
Nov 12, 2005
Messages
299
Also note that, if I'm not mistaking, the current stable version does not support disabled triggers and conditions. It's also not recommended to destroy triggers. Preview purposes only, next version will have a fix for this stuff.
 
Status
Not open for further replies.
Top