CodeWalrus

Development => Calculators => Calculator News, Coding, Help & Talk => Topic started by: SiphonicSugar on December 01, 2015, 05:08:59 AM

Title: Lua Key Check (TI-Nspire)
Post by: SiphonicSugar on December 01, 2015, 05:08:59 AM
So, what would be some example of code that would check if I have pressed the tab button, and if I press tab, add 1 to x?
Title: Re: Lua Key Check (TI-Nspire)
Post by: Ivoah on December 01, 2015, 05:19:55 AM
Lua key presses work with callbacks. The on.tabKey function is called whenever the tab key is pressed, and on.arrowKey when an arrow key is pressed, etc...
Title: Re: Lua Key Check (TI-Nspire)
Post by: Dream of Omnimaga on December 01, 2015, 05:38:17 AM
Isn't there a key map somewhere for Lua with the valid key names in code form? (eg tabKey) We have that for Axe and BASIC, although with numbers.
Title: Re: Lua Key Check (TI-Nspire)
Post by: Adriweb on December 01, 2015, 05:39:37 AM
Well, see the Nspire-Lua API PDF from TI or https://wiki.inspired-lua.org/Category:Events
on.charIn is probably what you want for non-arrow and non-special keys.
Title: Re: Lua Key Check (TI-Nspire)
Post by: Dream of Omnimaga on December 01, 2015, 05:41:09 AM
Oh I meant a graphical key map, like this, not a list:

(http://tifreakware.net/tutorials/83p/b/tifw/im/83plusgetkey.gif)

But thanks anyway. I'll also check the PDF later to see if it has a graphical key map.
Title: Re: Lua Key Check (TI-Nspire)
Post by: semiprocoder on December 01, 2015, 11:58:20 AM
Oh. Unfortunately as far as I know there is no keymap because they don't have a universal getkey command. There are just interrupts called that ld studios linked.

Also here is an example of a code that increments x when you press the tab button:

function on.tabKey()
   x=x+1
end
Title: Re: Lua Key Check (TI-Nspire)
Post by: SiphonicSugar on December 01, 2015, 09:18:13 PM
Thanks for the help, I will probably use this topic to ask more Lua questions later.
Title: Re: Lua Key Check (TI-Nspire)
Post by: Dream of Omnimaga on December 02, 2015, 06:42:35 AM
Quote from: semiprocoder on December 01, 2015, 11:58:20 AM
Oh. Unfortunately as far as I know there is no keymap because they don't have a universal getkey command. There are just interrupts called that ld studios linked.

Also here is an example of a code that increments x when you press the tab button:

function on.tabKey()
   x=x+1
end

I see. Interesting. That's definitively something I would need to get used to if I learned Lua I guess, but again I don't plan to do TI-Nspire dev. Good luck SiphonicSugar!