Key pressed

More
1 week 2 days ago #223 by ludojoey
Key pressed was created by ludojoey
There is a way to determine which key was pressed by using its key code, but I can't find any function that tells me which key was pressed in terms of its ASCII code.

Unless I'm missing something, if I want to know the ASCII value of the pressed key, do I have to perform the conversion myself?

Also, regarding special key combinations (Shift + key, FCTN + key, Ctrl + key), is it up to my application to detect whether one of these modifier keys was pressed immediately before the actual key?

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago - 1 week 2 days ago #224 by Franck
Replied by Franck on topic Key pressed
Indeed as of now you have to perform the conversion manually. This is a good candidate for a small reusable utility function.

Regarding modifier keys the best practice is to use the built-in FIFO to ensure no key event gets lost and they are stored in the correct order. Example:
Code:
//globals (cannot be locals to the main loop because they need to maintain their states across iterations) bool FCTN; bool ALT; //main loop starts here byte keyDwn=getKeyDwn(); byte keyUp=getKeyUp(); if(keyDwn==79) FCTN=true; else if(keyDwn==71) ALT=true; //continue here with other keyDwn tests such as regular keys //then the keyUp tests: if(keyUp==79) FCTN=false; else if(keyUp==71) ALT=false; //end of main loop


Hope that helps.
Last edit: 1 week 2 days ago by Franck.
The following user(s) said Thank You: ludojoey

Please Log in or Create an account to join the conversation.

Time to create page: 0.158 seconds
Powered by Kunena Forum