SFML community forums
General => General discussions => Topic started by: TULOA on June 06, 2011, 11:13:02 pm
-
Is it possible to trigger an event or setup a listener on key up instead of key press?
For instance when they release the key it would add whatever key to the string. It would help for homemade user input for graphical programs. Otherwise I have to put in a delay so it isnt a million times a second >.<
I know C++ native has a WM_KEYUP or something like it.
-
From the documentation: http://www.sfml-dev.org/documentation/1.6/classsf_1_1Event.php
enum EventType {
...
TextEntered,
KeyPressed,
KeyReleased,
...
}
Please try to find the answer yourself first before asking a question. Doing research on your own is always appreciated and is more or less a requirement in this profession.
-
Ok but I was hoping for more of an example of how to use it.
-
Also from the tutorial: http://www.sfml-dev.org/tutorials/1.6/window-events.php
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
// Window closed
if (Event.Type == sf::Event::Closed)
App.Close();
// Escape key pressed
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
}
Just change KeyPressed to KeyReleased.
Seriously, try to look around first.
-
Is it possible to trigger an event or setup a listener on key up instead of key press?
Polling events can be done in SFML. To setup listeners, you can use the thor::SfmlEventSystem class of my library ;)
-
Hurray a new issue....
I saw it discussed but is there any plans to fix or add a key for the Numpad Delete/Period Key?
Right now it isn't recognized and I have no idea how to edit SFML to include it for my project.
-
You can download the latest SFML 2 snapshot on the downloads page (http://www.sfml-dev.org/download.php), edit the source code, and recompile the DLLs. A program called CMake can help you create the solution for your compiler of choice. Hopefully he will implement it eventually.