SFML community forums

Help => General => Topic started by: Chay Hawk on October 04, 2014, 08:17:27 pm

Title: Get keyboard button?
Post by: Chay Hawk on October 04, 2014, 08:17:27 pm
I was wondering if there was a way to get whatever key was pressed without having to program them all into my program. I'm making a keylogger for personal use and I would like to know if there is an easier solution to this or do I have to program in all of the keys myself.
Title: Re: Get keyboard button?
Post by: Mario on October 04, 2014, 08:35:37 pm
What exactly do you mean? The keyboard event's data will include the key code. Or do you mean some way to get a textual representation of the key (i.e. key code to string)?
Title: Re: Get keyboard button?
Post by: Chay Hawk on October 04, 2014, 08:41:43 pm
Well, I mean if i press a button I want it to output whatever key was pressed to a text file without me having to hard code every key on the keyboard.
Title: Re: Get keyboard button?
Post by: zsbzsb on October 04, 2014, 08:44:14 pm
You really need to answer Mario's question. We aren't mind readers here and can't know the output you want.
Title: Re: Get keyboard button?
Post by: Chay Hawk on October 04, 2014, 08:49:05 pm
What i want to do is be able to press a button on my keyboard and have SFML figure out by itself which key I pressed, I dont want to code all buttons on my keyboard, then output a string representation of that key to a text file.
Title: Re: Get keyboard button?
Post by: zsbzsb on October 04, 2014, 08:56:09 pm
You know what? What is clear that you want to yourself is not clear to other people when you continue to write very ambiguous replies even when asked to clarify what you mean. Mario gave you very clear choices.

What exactly do you mean? The keyboard event's data will include the key code. Or do you mean some way to get a textual representation of the key (i.e. key code to string)?

That said, if you want the textual representation of the key take a look at Thor (http://www.bromeon.ch/libraries/thor/v2.0/doc/group___input.html#ga9fa0ada1ea1484ae34441317fb8b0a19).
Title: Re: Get keyboard button?
Post by: Ixrec on October 04, 2014, 09:39:52 pm
Have you looked at the TextEntered event? That sounds like what you're trying to ask for, since it returns a Unicode code point instead of a key code.