Keyboard Input types

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
Vesper

Keyboard Input types

Post by Vesper »

I've followed the tutorial for movement, and that was all fine. However, I tweaked the code a bit. I attempted to gain steady movement by holding down a key, such as an arrow key.

After randomly guessing to check for KEY_KEY_UP, I noticed some odd behaviour. The box responded just like a word processor; accept the input once, pause, then repeat rapidly.

I don't want a word-processor-type input. I want simple on and off. I've done it before successfully in OpenGL. However, I don't want to write my programs to use a few Irrlicht commands in an OpenGL shell. (That might provide even more issues to deal with.) Could that be the only way? Or is there a simpler method of implementing digital keyboard input?
Bluelight
Posts: 31
Joined: Mon Sep 19, 2005 10:25 pm
Location: Norway
Contact:

Post by Bluelight »

BlueLight
Guest

Post by Guest »

could you plz post an example of how to get that to work, it doesnt work with me
Bluelight
Posts: 31
Joined: Mon Sep 19, 2005 10:25 pm
Location: Norway
Contact:

Post by Bluelight »

Hmm.. What about this..?

class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
/*
If the key 'W' or 'S' was left up, we get the position of the scene node,
and modify the Y coordinate a little bit. So if you press 'W', the node
moves up, and if you press 'S' it moves down.
*/

if (node != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT&&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = node->getPosition();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
node->setPosition(v);
}
return true;
}
}

return false;
}
};
BlueLight
Guest

Post by Guest »

lol thanks but ive already had that exact code (well near enough) its alright now anyway but thanks :)
Post Reply