Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
General
»
Get Keyboard input without a window(Console)
Print
Pages: [
1
]
Author
Topic: Get Keyboard input without a window(Console) (Read 5283 times)
0 Members and 1 Guest are viewing this topic.
Ragbot
Newbie
Posts: 24
Get Keyboard input without a window(Console)
«
on:
May 09, 2021, 09:02:11 pm »
I cant get user input without a window,
because I have to use
while
(
window.
pollEvent
(
event
)
)
{
switch
(
event.
type
)
{
}
}
So, is there any way for me too get user input without a window?
Logged
G.
Hero Member
Posts: 1593
Re: Get Keyboard input without a window(Console)
«
Reply #1 on:
May 10, 2021, 07:51:27 am »
C++ standard input, cin, if you want to get some text or numbers from your console
https://www.cplusplus.com/doc/tutorial/basic_io/
sf::Keyboard::IsKeyPressed if you have other needs...
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Keyboard.php
Logged
Ragbot
Newbie
Posts: 24
Re: Get Keyboard input without a window(Console)
«
Reply #2 on:
May 10, 2021, 01:31:11 pm »
Is there a way to get the input only when it got pressed,
Like a short pulse?
like WM_KEYDOWN?
Logged
G.
Hero Member
Posts: 1593
Re: Get Keyboard input without a window(Console)
«
Reply #3 on:
May 10, 2021, 05:25:16 pm »
You'd have to keep an array of what keys are pressed, update it every step of your main loop, and when a key is pressed but wasn't pressed before it will mean it has been pressed right now, like a "short pulse" I guess
Logged
Ragbot
Newbie
Posts: 24
Re: Get Keyboard input without a window(Console)
«
Reply #4 on:
May 11, 2021, 02:11:41 pm »
I didn't understand can I like get a pseudo code?
Quote
You'd have to keep an array of what keys are pressed
Like in an array?
so do we do it like this :
if
(
array.
at
(
array.
size
(
)
)
==
sf
::
Keyboard
::
K
)
{
// Do stuff //
}
is it like that? or
«
Last Edit: May 11, 2021, 02:13:24 pm by Ragbot
»
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
General
»
Get Keyboard input without a window(Console)