How to test if the INSERT key is active

Posted on 1998-09-21
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.
Question by:Malensek
  • 2
  • 2

Accepted Solution

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;
 keystate:byte absolute $40:$17;
 INSERTactive := (keystate and 128 = 0);

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

Expert Comment

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.

Expert Comment

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

  mov  ah,12h
  int  16h
  mov  al,Status
  mov  ah,EStatus


Expert Comment

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');

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to Use TTouchKeyboard inherit 1 1,464
USB Flash Drive Serial Numbers 9 3,897
Problem inserting a record into SQL Server database from Delphi 10 995
add combobox item based on numbers 9 122
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

19 Experts available now in Live!

Get 1:1 Help Now