Hi Pro's,
I am making a basic Lua console which involves inputting text and when you press enter that code being run. I am trying to implement a copy and paste feature however when I press "v" on the keyboard the love.keypressed(sKey) function thinks I pressed "lctrl" for some reason and so I cannot implement a ctrl+v key detection.
A copy of the code can be found here http://pastebin.com/24uusABT. On line 67 I check for the user pressing "v" and if the ctrl key is down. if you take a look at line 66 you will see I record any key the user presses in a var and I display that in the top line of the console for troubleshooting, you can use this to test for yourselves
I am using love 0.9.0 so I could possibly use the love.textinput(sText) function however I would like to implement it in the keypressed function if possible. Any assistance would be greatly appreciated
EDIT: I cannot even use the textinput function as it does not detect the "v" when I press ctrl+v
love.keypressed detecting keys incorrectly
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: love.keypressed detecting keys incorrectly
Replace line 67 with this:KaoS wrote:On line 67 I check for the user pressing "v" and if the ctrl key is down.
Code: Select all
if key=="v" and love.keyboard.isDown("lctrl","rctrl") then
I don't understand how you made this mistake since on line 78 you use the correct function. Walk it out.bat is awesome
Re: love.keypressed detecting keys incorrectly
I'm not calling it. I define the function and every time a user presses a key then love2d calls it with the key that was pressed as the first parameter. So when the function is called if the first parameter is "v" and the ctrl key is down then paste...
and thanks I just randomly felt like coding in batch one day, I'm starting to doubt my sanity... I think KaoShell and infiT are 10x cooler though
and thanks I just randomly felt like coding in batch one day, I'm starting to doubt my sanity... I think KaoShell and infiT are 10x cooler though
Re: love.keypressed detecting keys incorrectly
Yes you ARE calling it on line 67. The callback starts at line 64, calling the callback inside itself is nonsense.KaoS wrote:I'm not calling it.
This is what you're doing wrong, do you see it?
Code: Select all
function love.keypressed(key)
if bConsoleActive then
lastkey=key
if key=="v" and love.keypressed("lctrl","rctrl") then --ctrl+v
Re: love.keypressed detecting keys incorrectly
You could also use love.textinput as far as I know.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Re: love.keypressed detecting keys incorrectly
Oh my word... this is the most n00by mistake I have ever made to date I am embarrassed by the existence of this thread. I apologise for wasting your time. Also you cannot use textinput because if you press ctrl+v it does not call textinput at all
Re: love.keypressed detecting keys incorrectly
My bad. Good to know, though.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests