English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to have a button that would do the same as shift, so the next button would be uppercase

Also, caps lock

yes, i am building a keyboard

2006-08-21 15:20:26 · 1 answers · asked by stepanstas 2 in Computers & Internet Programming & Design

1 answers

umm.. I'll take a stab.
you'll have to set up some flags to set the state of the shift or caps lock keys.


define two global boolean variables.

bShiftPressed as boolean
bCapsLock as boolean.

default both to false
sub Shift_pressed()

When the shift button is clicked,
toggle bShiftPressed.

if bShiftPressed then
bShiftPressed=false
else
bShiftPressed=true
end if
end sub

sub capslock_pressed()

'when the caps lock key is pressed, toggle bCapsLock:

if bCapsLock then
bCapsLock=false
else
bCapsLock=true
end if
end sub

when any other key is pressed:

Function KeyPress(byval thekey as string) as string
'if either one is true, then an upper case character
'is returned.

if (bCapsLock or bShiftPressed) then
thekey=ucase(keypressed)
else
'neither is true, so it's lowercase
thekey=lcase(keypressed)
end if

'the caps lock key reverses the shift functionality
'so, if caps lock is on, AND the shift key is pressed, a
'LOWER case letter comes out

if(bCapsLock and bShiftPressed)
thekey=lcase(keypressed)
end if
'set bShiftPressed to false
'so that it only counts for 1 character
bShiftPressed=false
kepressed=thekey

end function

2006-08-21 16:08:30 · answer #1 · answered by ZressE 3 · 0 0

fedest.com, questions and answers