This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LeviM's profile picture

Give Char event instead of Key event?

Started by LeviM, 15 February 2015 - 02:06 PM
LeviM #1
Posted 15 February 2015 - 03:06 PM
I am creating an operating system for a friend of mine on my server. The login can't use read() because he wants it to 'flow'. I have a while loop that gets events and if they meet certain criteria they do something. When I click a key it will give a 'key' event instead of a 'char' event. Can I make it give off a char event or do I have to code in all of the key's?
InDieTasten #2
Posted 15 February 2015 - 03:11 PM
Can you explain in more detail: Most of the buttons on your keyboard will fire both, a key event and a char event. Some of them, mostly the keys for control only fire key events, as they don't represent a char ;)/>
I hope this was helpful, otherwise you would need to describe your problem in more detail
MKlegoman357 #3
Posted 15 February 2015 - 03:13 PM
It is giving the char event only if the character pressed is a writable character. For example if you press [x] then you will get two events: "key" with a parameter 45 and another event "char" with parameter "x". But if you press [left shift] then you will only get a "key" event with a parameter 42. Note that one event may come before the other, ie.: "key" event might fire before "char" event, but if your event-loop is set correctly then you shouldn't be worrying about this.
LeviM #4
Posted 15 February 2015 - 03:31 PM
I'm an idiot. It does this anyways. Thanks for help anyways!
Edited on 15 February 2015 - 02:32 PM