Solved

How to test if the INSERT key is active

Posted on 1998-09-21
4
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Check out this step-by-step guide for asking an anonymous question on Experts Exchange.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
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…

734 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