# PureBasic Forum

 It is currently Fri Feb 21, 2020 6:10 am

 All times are UTC + 1 hour

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: keyboardpushed(#PB_Any_Letter)Posted: Thu Jun 20, 2019 10:04 pm
 User

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 82
Location: Netherlands
When i put in a code e.g.
Code:
TheKey = KeyboardPushed(#PB_Key_RightAlt)

The result is 128 and not 1 if key is pressed.

The description say non zero. And the bottum line say 1 if key is pressed.
In bitwize notation 128 is bit number 7. and not bit number 0.

_________________
From my first self made computer till now I stil like computers.

Top

 Post subject: Re: keyboardpushed(#PB_Any_Letter)Posted: Thu Jun 20, 2019 11:58 pm
 Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 569
I don't know what "bottom line" you're talking about, but the manual says: "Nonzero if the specified key is pushed, zero otherwise."

So, as Metallica says: nothing else matters. Test for zero or non-zero only to make it work as documented and intended.

Top

 Post subject: Re: keyboardpushed(#PB_Any_Letter)Posted: Sun Jun 23, 2019 7:03 pm
 User

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 82
Location: Netherlands

When you are in the IDE and type in
KeyboardPushed(...
You see at the bottom line the short explenation of using the function.
And that says: KeyboardPushed(KeyID) Returns a 1 if the assinged key is pressed. otherwise 0.

So you may think that the pressing of the key, gives you a 1 like #True. But i got a 128 value returned.
That put me on the wrong foot. When i try to write some code and you see the bottom line. you make up the wrong code.

Now i know that the last bit is set and not the first i can work with that. Every key give back a 128 value (Bit#7 is a 1). This is easy to convert to a 1 value (Bit #0 is a 1)
By making a procedure testing the key and give back the value i need.

Thanks guy's

_________________
From my first self made computer till now I stil like computers.

Top

 Post subject: Re: keyboardpushed(#PB_Any_Letter)Posted: Sun Jun 23, 2019 7:23 pm
 Enthusiast

Joined: Sat Jul 23, 2011 1:13 am
Posts: 235
Location: Germany
True. The quick-tip in the IDE differs from the help file.
Case for bugs: Documentation viewforum.php?f=37

I posted the mistake: viewtopic.php?f=37&t=73080

Top

 Post subject: Re: keyboardpushed(#PB_Any_Letter)Posted: Mon Jun 24, 2019 12:02 am
 Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 569
bfernhout wrote:
You see at the bottom line the short explenation of using the function.
And that says: KeyboardPushed(KeyID) Returns a 1 if the assinged key is pressed. otherwise 0.

Oh, bottom line = status bar of the IDE. Yes, it says something different to the Help. Now I get what you mean.

Top

 Post subject: Re: keyboardpushed(#PB_Any_Letter)Posted: Tue Jul 16, 2019 9:16 am
 User

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 82
Location: Netherlands
Thanks for the post.
It is something that can bring new people on the wrong foot.

Still this is the best way to make programs. If I make the same program in C++, then they are alway larger and slower. I talk about say Purebasic run a program on 300 ms and the compiled and optimized c++ runs on a avarage of 380 ms.
Only when i make the program in Assembler the compiling create a smaller program and run faster.

But then again PB is beter and easyer to program.

_________________
From my first self made computer till now I stil like computers.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 6 posts ]

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: No registered users and 3 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite