Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / keyboard entry and scancode return

Author
Message
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 24th Jul 2009 07:09
I thought this would probably be pretty useful for some people.

The first function DB_KeyEntry() creates a string from the keys you've pressed.

The second function DB_Letters(scancode()) returns the letter/symbol that the scancode would stand for.

*I know it sounds similar to inkey$(), but this command can return multiple letters/symbols.*

In the download is an example of the text entry, scancode return for letter/symbol, and multiple letters/symbols return.

Attachments

Login to view attachments
Brick Break
User Banned
Posted: 24th Jul 2009 09:09
A few things:
DB_KeyEntry() is pretty much the same as entyr$(), why do they start with DB, and how come you couldn't make a function to detect whether a certain key is in or not using the entry buffer? This seems very helpful, but at the same time a waste.

WINNER list:
Latch, Lee Bamber, TDK, TheComet
Thanks for the help!
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 25th Jul 2009 00:52
Well what I was originally trying to do was make a function that would save what you type to a string. The only problem is I would either have to check each keystate individually, or use inkey$ which would work because it registers the key farthest to the left for example:

Ex. If I'm holding the "G" key and then push down on the "H" key it will register the "G" key first because it's farther to the left on the keyboard.

And the final problem was scancode, because like inkey$ it will only return the key being pushed farthest to the left.

So that's how the second function was created. I also like the second function because if you have the scancode of something you can find out what letter or symbol that code stands for, just by using the function.


I'm not really sure of what the entry$() command is so I didn't bother with it. I don't understand the whole buffer thing, but if you could help out with an explanation of it. I could try and whip something up.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Jul 2009 01:04
Haven't checked it out yet, but it DOES sound like entry$() (records all keypresses to a single string). However, if your program is a little smarter than entry$() (takes into accound backspace, shift, and other significant keys) then that could be a real help

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 25th Jul 2009 01:09
It takes into account backspace and shift.

Login to post a reply

Server time is: 2024-05-20 06:12:47
Your offset time is: 2024-05-20 06:12:47