• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

KeyboardAPI

Status
Not open for further replies.

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
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:
 

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
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.
 

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
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