Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Input.KeyDown
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JSBN




PostPosted: Fri Jun 20, 2003 3:11 pm   Post subject: Input.KeyDown

For Input.KeyDown, how do i detect an uppercase letter (ie. A)
i know to detect shift it is (KEY_SHIFT) and for a it is ('a').
Itried puting the 2 togeather, that d'dn't work, and i tried ('A'), but that didn't work either.
:/
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Jun 20, 2003 9:35 pm   Post subject: (No subject)

you check for both at same time.

if chars(Key_SHIFT) and chars('a') then
...
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
JSBN




PostPosted: Sat Jun 21, 2003 12:05 am   Post subject: (No subject)

i already tried that :/
Blade




PostPosted: Sat Jun 21, 2003 9:16 am   Post subject: (No subject)

tony is right.... if you go to the help file, then...
Quote:
The array returned is a list of all the characters. A key is currently pressed if the array element with the corresponding character is true. For example, the a key is pressed is chars ('a') is true. Note that each key is individually represented, so if the user has pressed Shift+a to get a 'A', then Input.KeyDown would register Shift and 'a' as pressed, but not 'A'.

and this works for me
code:
var chars : array char of boolean
loop
    Input.KeyDown (chars)
    if chars ('a') & chars (KEY_SHIFT) then
        put "hi"
    else
        put "bye"
    end if
    locate (1, 1)
end loop
JSBN




PostPosted: Sun Jun 22, 2003 12:43 pm   Post subject: (No subject)

ok, i figured out my problem, i had it set up wrong.
i had:
code:
if chars ('a') then
...
elsif chars ('a') and chars (KEY_SHIFT) then
...

what u need is :
code:
if chars ('a') and chars (KEY_SHIFT) then
...
elsif chars ('a') then
...

THe upper case letter MUST go b4 the lowercase letter
THx for your help, and esspecially to blade for makingme relize this.
JSBN




PostPosted: Mon Jun 23, 2003 6:23 pm   Post subject: (No subject)

another question, I was wondering what Caps lock was.
Homer_simpson




PostPosted: Mon Jun 23, 2003 6:28 pm   Post subject: (No subject)

i dont think that input keydown supports capslock =/
Asok




PostPosted: Mon Jun 23, 2003 6:40 pm   Post subject: (No subject)

if ANYONE knows how to detect caps lock via Input.Keydown they'll get 25 bits. (must provide source code)
Homer_simpson




PostPosted: Mon Jun 23, 2003 8:08 pm   Post subject: (No subject)

lol if anyone finds out how to do that using turing... he'll get 100 bits...(knowing that it's impossible...)
Andy




PostPosted: Mon Jun 23, 2003 8:23 pm   Post subject: (No subject)

ya it is impossible... can you even detect if shift is pressed?
Catalyst




PostPosted: Mon Jun 23, 2003 8:26 pm   Post subject: (No subject)

u people...

code:
var chars : array char of boolean
var key : string (1) := "!"
fcn capTest (k : string (1)) : boolean
    if ord (k) >= 65 and ord (k) <= 90 then
        result true
    else
        result false
    end if
end capTest
loop
    getch (key)
    Input.KeyDown (chars)
    if chars (KEY_SHIFT) = false and capTest (key) then
        put "Caps Lock is on"
    elsif chars (KEY_SHIFT) = true and capTest (key)=false then
        put "Caps Lock is on"       
    else
        put "Caps Lock is off"
    end if
end loop
Andy




PostPosted: Mon Jun 23, 2003 8:30 pm   Post subject: (No subject)

catalyst that only checks for letters and we want to know if caplocks is pressed without inputing data.
JSBN




PostPosted: Mon Jun 23, 2003 8:32 pm   Post subject: (No subject)

can u get so that there is no getch?
Catalyst




PostPosted: Mon Jun 23, 2003 8:34 pm   Post subject: (No subject)

i dont think i can do i withour getch since the only reason it works is that getch() picks up on the caps lock
Asok




PostPosted: Mon Jun 23, 2003 11:49 pm   Post subject: (No subject)

JSBN, that should work with what we're doing anyways because var key wont be drawn it just holds the status of caps lock.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: