Page 1 of 1

[SOLVED] Detecting special characters with love.textinput()

Posted: Fri Nov 02, 2018 12:05 am
by DGM
Hello,

I'm trying to make a simple command-line interface by using the love.textinput(text) function (this is with Love2d version 11.1). I've got text appearing but I can't get the program to recognize when the return key is pressed. I know I can do this with love.keypressed(key) by comparing key to "return", but this doesn't work with textinput. I've tried comparing to "\r\n" (which starts a new line when it appears in a string) as well as "\r" and "\n" separately but none of that works either.

Is there a way to do this with textinput() or do I have to fall back on keypressed() for special characters like this?

Re: Detecting special characters with love.textinput()

Posted: Fri Nov 02, 2018 12:59 am
by Alexar
"return" is not a kind of character but a ctrl command, so you can not get it from textinput(), so just use the keypress() func.

Re: Detecting special characters with love.textinput()

Posted: Fri Nov 02, 2018 3:50 am
by zorg
you do need to "fall back".

Re: Detecting special characters with love.textinput()

Posted: Fri Nov 02, 2018 4:59 am
by DGM
Fair enough. Thanks.