Solved

How to test if the INSERT key is active

Posted on 1998-09-21
4
214 Views
Last Modified: 2010-04-16
How to test if the INSERT key is active?
I have found out that this problem can be solved with interrupts. Unfortunately I have newer worked with interrupts, so I dont realy know overcome the problem.
0
Comment
Question by:Malensek
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
mlaiosa earned 20 total points
ID: 1215636
There is an even easyer solution. The BIOS keeps track of the insert key's state (although most programs dont take advantage of that).

I assume you are useing turbo pascal, the folowing code should work:

function INSERTactive:boolean;
var
 keystate:byte absolute $40:$17;
begin
 INSERTactive := (keystate and 128 = 0);
end;

you can replace the 128 in 'keystate and 128' with
64 for caps lock
32 for num lock
16 for scrool lock
8 for alt pressed
4 for ctrl pressed
2 for left shift pressed
1 for right shift pressed
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215637
This method is just what interrupt 16h service 02h does.
However, service 12h gives you extended status about the keboard, like which Alt (or Control) key - left or right and so on.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215638
Ohh, and working with interrupts: (in the pascal file)

var
  Status,EStatus:byte;
.
asm
  mov  ah,12h
  int  16h
  mov  al,Status
  mov  ah,EStatus
end;
.

0
 
LVL 1

Expert Comment

by:mlaiosa
ID: 1215639
you can change "absolute $40:$17;" to "absolute $40:$18;" to retreve the EStatus as showed by FuzzyLogic.  This information is not availble on some older (very older) BIOS's

format of status byte 2 (ie: things to 'and' it with):
128 .. 16 are the same as above.
 8      Pause state active
 4      Sys Req pressed
 2      Left Alt pressed
 1      Left Ctrl pressed


also, if you had the 'keystate' varible as stated above, and wanted to see if caps lock and num lock were active, you could do:

if (keystate and (64+32) = 0) then writeln('Caps and Num lock are active');
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Ransomware continues to grow in reach and sophistication, putting data everywhere at risk. Learn how to avoid being caught in its sinister clutches with these 11 key tips.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question