New topic: 

Keyboard and Keycodes question

<http://forums.realsoftware.com/viewtopic.php?t=47664>

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        plunkettphoto          Post subject: Keyboard and Keycodes 
questionPosted: Sun Apr 21, 2013 6:28 pm                                 
Joined: Fri Oct 10, 2008 7:14 pm
Posts: 89                2 questions related to the list of KeyCodes given in 
the Keyboard module of the Language Reference.

First, why are capital letters not listed and the example says 00 is a capital 
A when the list shows 00 as lower case a.

Second, how do you trap for the enter key.  Is the code for the main enter key 
the same as the code for the enter on the keypad?

I want to trap for the enter key in a text field and if pressed execute the 
code that's in the action event of a different pushbutton.

thanks   
                             Top                timhare          Post subject: 
Re: Keyboard and Keycodes questionPosted: Sun Apr 21, 2013 6:40 pm              
           
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12262
Location: Portland, OR  USA                Keycodes identify the physical key 
on the keyboard, so there is no difference between upper and lower case.  But 
if you're doing this in a textfield, use the KeyDown event and forget about 
keycodes.   
                             Top                plunkettphoto          Post 
subject: Re: Keyboard and Keycodes questionPosted: Mon Apr 22, 2013 10:21 am    
                             
Joined: Fri Oct 10, 2008 7:14 pm
Posts: 89                Function KeyDown(Key As String) As Boolean
  dim sKeyEntered As String
  
  sKeyEntered = key
  if sKeyEntered = "0D" then
  MsgBox("Enter")
  end if
  
  Return true
  
End Function


Ok, I'm missing something, like where are the definitions of the "keys" pressed 
in the keydown event.  I want to test for the ENTER key being pressed and I 
can't seem to find out what what to test FOR.  What do I need to do?

thanks,
b   
                             Top                msssltd          Post subject: 
Re: Keyboard and Keycodes questionPosted: Mon Apr 22, 2013 11:09 am             
                    
Joined: Fri Oct 28, 2005 7:05 am
Posts: 555
Location: Emsworth, UK                Here is an example, reworked from the 
Language Reference

Sub KeyDown(key as string) as boolean
  
  //note that 'key' is a string - the binary representation of single character
  // Key is converted to an ordinal representation using Asc(key)
  Select Case key.Asc
  Case &h0D //Return key pressed
  Case &h03 //Enter key on numeric keypad pressed
  Case &h20 //Space bar pressed
  End Select


I think using the hex literal notation (&h00) is confusing in this instance.  I 
used hex literals in the example to  help highlight where you have 
misunderstood.  Plain old decimal 13, 3, 32 works just as well.

I find the quickest way to find the right number is to test it yourself.
Sub KeyDown( key as string) as boolean
  dim ch as integer = key.Asc
  TextArea1.AppendText "You pressed the key " + Str(ch) + EndOfLine
End
      
_________________
Yes it's me in the avatar  
                             Top                plunkettphoto          Post 
subject: Re: Keyboard and Keycodes questionPosted: Mon Apr 22, 2013 11:58 am    
                             
Joined: Fri Oct 10, 2008 7:14 pm
Posts: 89                thanks msssltd

that worked like a champ,

b   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to