How to do KeyUp Event?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
chaiein
Posts: 30
Joined: Wed Apr 11, 2012 6:51 am

How to do KeyUp Event?

Post by chaiein »

I have the following code how to give KeyUp event I have error presently

Code: Select all

  virtual bool OnEvent(const SEvent& event)
    {
                if (event.EventType == irr::EET_KEY_INPUT_EVENT)
                {
                KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
 
                }
                else if(event.Eventype==irr::EET_KEY_INPUT_EVENT)
                {
                        KeyIsUp[event.KeyInput.Key]=event.KeyInput.PressedUp;
                }
        return false;
    }
I am getting error at PressedUp.

What and where should i write the code for KeyUp Event.
Last edited by chaiein on Tue Apr 17, 2012 3:01 am, edited 2 times in total.
CuteAlien
Admin
Posts: 10027
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to do KeyUp Event?

Post by CuteAlien »

When you have an error don't just say I have an error. The important info is _which_ error! So please copy-paste it.
Exact error-messags are always the most important part of any error-report.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chaiein
Posts: 30
Joined: Wed Apr 11, 2012 6:51 am

Re: How to do KeyUp Event?

Post by chaiein »

The Error I get is 'PressedUp' : is not a member of 'irr::SEvent::SKeyInput'
CuteAlien
Admin
Posts: 10027
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to do KeyUp Event?

Post by CuteAlien »

Well, that error-message can't be much more clear I guess. You get the error because it is not a member of that struct:
http://irrlicht.sourceforge.net/docu/st ... input.html

But if you think a little about it you probably realize that you don't need the whole "else if" part anyway. Actually that it can't even work that way. First you check for the same condition in the "if" than in the "else if" - but if the condition is met for "if" then it never even tries the "else" (and also when the condition is not met it will still not be met when checking it a second time).

The other part is that your KeyIsDown is probably a bool array. You try creating a second array for KeyIsUp... but think for a moment about this. KeyIsDown is either true or false. Now what does it mean when KeyIsDown is false... yep - you already got your up.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chaiein
Posts: 30
Joined: Wed Apr 11, 2012 6:51 am

Re: How to do KeyUp Event?

Post by chaiein »

ok Thank you CuteAlien:)
Post Reply