Solved

How to test if the INSERT key is active

Posted on 1998-09-21
4
207 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A procedure for exporting installed hotfix details of remote computers using powershell
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now