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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
DGM
Prole
Posts: 16
Joined: Tue Mar 20, 2018 6:42 am

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

Post 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?
Last edited by DGM on Fri Nov 02, 2018 5:00 am, edited 1 time in total.
User avatar
Alexar
Party member
Posts: 174
Joined: Thu Feb 05, 2015 1:57 am
Location: Chengdu,China

Re: Detecting special characters with love.textinput()

Post 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.
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Detecting special characters with love.textinput()

Post by zorg »

you do need to "fall back".
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
DGM
Prole
Posts: 16
Joined: Tue Mar 20, 2018 6:42 am

Re: Detecting special characters with love.textinput()

Post by DGM »

Fair enough. Thanks.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 27 guests