Check if CTRL or ALT is pressed 
Author Message
 Check if CTRL or ALT is pressed

How can I check if there's pressed on Ctrl or Alt, I want to make a platform
game, and I want to use ctrl for jumping, but it only works if I've typed
another key too.


Wed, 18 Jun 1902 08:00:00 GMT  
 Check if CTRL or ALT is pressed

Quote:
>How can I check if there's pressed on Ctrl or Alt, I want to make a platform
>game, and I want to use ctrl for jumping, but it only works if I've typed
>another key too.

VAR
  x : Word ABSOLUTE $0040:$0017;

and x contains several bits that refer to the shift/ctrl/alt/ins/etc.
keys.

Regards,

Martijn Leisink



Wed, 18 Jun 1902 08:00:00 GMT  
 Check if CTRL or ALT is pressed

Quote:


>:   x : Word ABSOLUTE $0040:$0017;
>Better use memw[Seg0040:$17] or you will find a {*filter*}
>surprise if you ever compile this for protected mode.

You're right.  I never compile for prot. mode :-)

Regards, Martijn



Wed, 18 Jun 1902 08:00:00 GMT  
 Check if CTRL or ALT is pressed
why not trying to create a interrupt handler at int 9h?
it's more directly

sample prog:

var
 mainkey:byte;
oldvec:procedure;
gotint:boolean;

Procedure KeyHandler; Interrupt;
var
  key:byte;

begin
  key:=port[$60];
  {note that the key's must be remembered..}
  {for example}
  {when a user presses A ,the KEY var will }
  {be filled with it's code..}
  {when a user releases A ,the KEY var will }
  {be PREVKEY+128}
  {to figure out what keycode belongs to specific key??}
  {just watch the following code}
  mainkey:=key;
  gotint:=true;
  oldvec;
end;

begin


repeat
  if gotint and mainkey<128 then begin
   writeln ('User pressed something on the keyboard ,it''s ',mainkey);
   gotint:=false;
  end;
  if gotint and mainkey>127 then begin
  writeln ('User released a key ,it was ',mainkey-128);
  gotint:=false;
 end;
until mainkey=1; {mainkey of 1 is the ESC button :)}
end.


Quote:

(Klaus Hartnegg) writes:



writes:

>>:   x : Word ABSOLUTE $0040:$0017;

>>Better use memw[Seg0040:$17] or you will find a {*filter*}
>>surprise if you ever compile this for protected mode.

>You're right.  I never compile for prot. mode :-)

>Regards, Martijn



Wed, 18 Jun 1902 08:00:00 GMT  
 Check if CTRL or ALT is pressed
oops ,forgot something..


Quote:
>why not trying to create a interrupt handler at int 9h?
>it's more directly

>sample prog:

>var
> mainkey:byte;
>oldvec:procedure;
>gotint:boolean;

>Procedure KeyHandler; Interrupt;
>var
>  key:byte;

>begin
>  key:=port[$60];
>  {note that the key's must be remembered..}
>  {for example}
>  {when a user presses A ,the KEY var will }
>  {be filled with it's code..}
>  {when a user releases A ,the KEY var will }
>  {be PREVKEY+128}
>  {to figure out what keycode belongs to specific key??}
>  {just watch the following code}
>  mainkey:=key;
>  gotint:=true;
>  oldvec;
>end;

>begin


>repeat
>  if gotint and mainkey<128 then begin
>   writeln ('User pressed something on the keyboard ,it''s ',mainkey);
>   gotint:=false;
>  end;
>  if gotint and mainkey>127 then begin
>  writeln ('User released a key ,it was ',mainkey-128);
>  gotint:=false;
> end;
>until mainkey=1; {mainkey of 1 is the ESC button :)}

that's what i forgot

 >> setintvec ($9,oldvec);

- Show quoted text -

Quote:
>end.




>(Klaus Hartnegg) writes:



>writes:

>>>:   x : Word ABSOLUTE $0040:$0017;

>>>Better use memw[Seg0040:$17] or you will find a {*filter*}
>>>surprise if you ever compile this for protected mode.

>>You're right.  I never compile for prot. mode :-)

>>Regards, Martijn



Wed, 18 Jun 1902 08:00:00 GMT  
 Check if CTRL or ALT is pressed

Quote:
>why not trying to create a interrupt handler at int 9h?
>it's more directly

Yea, absolutely!

 You don't even need to call the original keyboard routine, when you do this!
A Long, long time ago, I was trying to program an asteroids clone, and I
simply captured the keyboard interrupt. My new interrupt handler just read
the data from port $60 and put a true or false value into an array.
true-key has been pressed
false-key has been released.

This method has a nice side-effect, which allows you to handle
simultaneous pressing of multiple keys.

                                                                BUBAK



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to check for shift/ctrl/alt ?

2. Ctrl-Alt-Del&Ctrl-Brk

3. Disable CTRL-ALT-DEL

4. Disable CTRL-ALT-DEL

5. RESET OVERRIDE (CTRL-ALT-BREAK) ??

6. RESET OVERRIDE (CTRL-ALT-BREAK) ??

7. Disabling ctrl-alt-delete under win32

8. help with alt-ctrl keys

9. disable CTRL+ALT+DEL

10. Need Help Trapping Ctrl-Alt-Del

11. ctrl-alt-del

12. Simulating CTRL key press?

 

 
Powered by phpBB® Forum Software