Arrow Key Codes... - ASM x86 ASM 370

This is a discussion on Arrow Key Codes... - ASM x86 ASM 370 ; I am working on a input routine that uses AH=06h Direct Console I/O of the INT 21h DOS interrupt. It seems when I print the recieved character from the keyboard, when I have pressed the arrow keys, it prints two ...

+ Reply to Thread
Results 1 to 9 of 9

Arrow Key Codes...

  1. Default Arrow Key Codes...

    I am working on a input routine that uses
    AH=06h Direct Console I/O of the INT 21h DOS interrupt.
    It seems when I print the recieved character from the keyboard,
    when I have pressed the arrow keys, it prints two characters.
    Why is this?
    And what is the keyboard really returning to the computer?

    Can anyone tell me what these values are, so I can
    test the returned character to see if it was an arrow key,
    and which one?


  2. Default Re: [Clax86list] Arrow Key Codes...

    On Sun, 9 Nov 2008 10:43:16 -0800 (PST)
    wolf3y3 <spamtrap@crayne.org> wrote:

    > It seems when I print the recieved character from the keyboard,
    > when I have pressed the arrow keys, it prints two characters.
    > Why is this?


    Keys which have no ASCII representation return two values, the first of
    which is zero. The second value tells you which key it is. For example,
    the second value for the up arrow key is the same as the value for the
    letter "H".

    --
    Chuck
    http://www.pacificsites.com/~ccrayne/charles.html


  3. Default Re: Arrow Key Codes...



    wolf3y3 wrote:
    > I am working on a input routine that uses
    > AH=06h Direct Console I/O of the INT 21h DOS interrupt.
    > It seems when I print the recieved character from the keyboard,
    > when I have pressed the arrow keys, it prints two characters.
    > Why is this?
    > And what is the keyboard really returning to the computer?
    >
    > Can anyone tell me what these values are, so I can
    > test the returned character to see if it was an arrow key,
    > and which one?


    The keyboard codes are two bytes: key-number (high byte) followed by
    character code (low byte).
    The special keys like function keys the return key number followed by
    a binary zero.
    The pad keys return the key number and the fixed number 224 (Hex #E0).
    The numeric keypad returns codes which depend on whether the number
    lock is on (gives a digit as character) or off (gives a binary zero).
    All keys are affected by which of the additional shift combinations
    are present.
    Since there are 256 possible key numbers, only some are actually used.

    There is one exception: the upper right key "/" returns #E02F, with
    the same key number as the far right enter key (#E00D).


  4. Default Re: Arrow Key Codes...

    If pad keys means, the arrow keys,
    what are the key numbers for the two byte
    codes that have the fixed value 224,
    and what direction do they represent?


  5. Default Re: Arrow Key Codes...

    On Sun, 9 Nov 2008 16:53:21 -0800 (PST), Terence
    <spamtrap@crayne.org> wrote:

    >
    >
    >wolf3y3 wrote:
    >> I am working on a input routine that uses
    >> AH=06h Direct Console I/O of the INT 21h DOS interrupt.
    >> It seems when I print the recieved character from the keyboard,
    >> when I have pressed the arrow keys, it prints two characters.
    >> Why is this?
    >> And what is the keyboard really returning to the computer?
    >>
    >> Can anyone tell me what these values are, so I can
    >> test the returned character to see if it was an arrow key,
    >> and which one?

    >
    >The keyboard codes are two bytes: key-number (high byte) followed by
    >character code (low byte).
    >The special keys like function keys the return key number followed by
    >a binary zero.
    >The pad keys return the key number and the fixed number 224 (Hex #E0).
    >The numeric keypad returns codes which depend on whether the number
    >lock is on (gives a digit as character) or off (gives a binary zero).
    >All keys are affected by which of the additional shift combinations
    >are present.
    >Since there are 256 possible key numbers, only some are actually used.
    >
    >There is one exception: the upper right key "/" returns #E02F, with
    >the same key number as the far right enter key (#E00D).
    >


    You can download my KEYCODE.EXE utility at
    <www.daqarta.com/download.htm> .
    (It's at the bottom of the page.) Note that this
    will only run properly under real-mode DOS;
    I seem to recall there was some problem if you try
    it under a normal Windows command prompt.

    Shows you all the scan codes as each key is hit or
    released. ESC ends the session. When it first
    starts it tells you how to see the BIOS codes
    instead, via a command line parameter. (Sorry,
    it's been so long since I used this that I don't
    recall the parameter!)

    You may find some real surprises, since certain
    keys produce a whole string of scan codes!

    Best regards,


    Bob Masta

    DAQARTA v4.51
    Data AcQuisition And Real-Time ****ysis
    www.daqarta.com
    Scope, Spectrum, Spectrogram, Sound Level Meter
    FREE Signal Generator
    Science with your sound card!


  6. Default Re: Arrow Key Codes...



    wolf3y3 wrote:
    > If pad keys means, the arrow keys,
    > what are the key numbers for the two byte
    > codes that have the fixed value 224,
    > and what direction do they represent?


    C:\FORTRAN>key
    pad
    48E0 pad up
    4BE0 pad left
    50E0 pad down
    4DE0 pad right
    number pad
    4800 number pad up (with number lock OFF)
    4B00 number pad left ...
    5000 number pad down ...
    4D00 number pad right ..
    control pad
    8DE0
    73E0
    91E0
    74E0
    control numb
    8D00
    7300
    9100
    7400
    shift pad
    48E0
    4BE0
    50E0
    4DE0
    shift num
    4838 8
    4B34 4
    5032 2
    4D36 6
    alt pad
    9800
    9B00
    A000
    9D00
    alt num (not applicable since gives codes 00 to 255


  7. Default Re: Arrow Key Codes...

    On Mon, 10 Nov 2008 13:24:26 GMT, (Bob Masta) <spamtrap@crayne.org>
    wrote:

    <snip>
    >You can download my KEYCODE.EXE utility at
    ><www.daqarta.com/download.htm> .
    >(It's at the bottom of the page.) Note that this
    >will only run properly under real-mode DOS;
    >I seem to recall there was some problem if you try
    >it under a normal Windows command prompt.
    >
    >Shows you all the scan codes as each key is hit or
    >released. ESC ends the session. When it first
    >starts it tells you how to see the BIOS codes
    >instead, via a command line parameter. (Sorry,
    >it's been so long since I used this that I don't
    >recall the parameter!)

    I wrote a program to do that, also. (Looks like it was back in 94)
    Seems to hook int 15h to get the keycodes.

    >You may find some real surprises, since certain
    >keys produce a whole string of scan codes!

    Mostly those keys that were added after the original 86 key keyboards.
    --
    ArarghMail811 at [drop the 'http://www.' from ->] http://www.arargh.com
    BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

    To reply by email, remove the extra stuff from the reply address.


  8. Default Re: Arrow Key Codes...

    On Mon, 10 Nov 2008 13:24:26 GMT, (Bob Masta)
    <spamtrap@crayne.org> wrote:

    >You can download my KEYCODE.EXE utility at
    ><www.daqarta.com/download.htm> .
    >(It's at the bottom of the page.) Note that this
    >will only run properly under real-mode DOS;
    >I seem to recall there was some problem if you try
    >it under a normal Windows command prompt.


    Just tested: Works fine under Vista (and probably
    XP). The problem arises when using a "DOS
    prompt" under Win95 (and probably all 9x): The
    program seems to work fine, but when you hit ESC
    to exit, Windows gives an error message and tells
    you that you should restart your system.

    There is no problem under Win95 if you go to
    "Start - Shutdown - Restart in MSDOS mode"
    and run from there. After you hit the concluding
    ESC, you are back at the command prompt.
    Entering "exit" will restart Windows.

    >Shows you all the scan codes as each key is hit or
    >released. ESC ends the session. When it first
    >starts it tells you how to see the BIOS codes
    >instead, via a command line parameter. (Sorry,
    >it's been so long since I used this that I don't
    >recall the parameter!)


    Use "keycode B" to see the BIOS codes instead of
    the scan codes.

    >You may find some real surprises, since certain
    >keys produce a whole string of scan codes!


    Best regards,


    Bob Masta

    DAQARTA v4.51
    Data AcQuisition And Real-Time ****ysis
    www.daqarta.com
    Scope, Spectrum, Spectrogram, Sound Level Meter
    FREE Signal Generator
    Science with your sound card!


  9. Default Re: Arrow Key Codes...

    I have my version, written in Fortan, calling an ASM routine below for
    listing purposes:
    It returns all keys and key shift combination and is based on just
    mov AX,1300h
    INT 16h
    There are five interesting uses of AL = 0,1,2,16,17
    The full 103 keyboard set is returned if AL=16 or 17; (including F11
    and F12 in all shifts).

    This routine is called as INPC(x) where x=0,1,2
    Shift status is returned with parameter 2

    name INPC
    public INPC
    sinpc segment
    assume CS:sinpc
    INPC proc far ;usage I=INPC(0/1/2/16/17)
    PUSH BP ;0=WAIT, 1=CHECK, #10=WAIT EXTENDED CODE,#11=CHECK
    EXTENDED
    MOV BP,SP ;2=GET SHIFT STATUS TO AL
    LES BX,dword ptr [bp+6]
    MOV AH,ES:[BX]
    AND AX,1300H
    TEST AH,01H
    JZ INPC2 ;IF NOT WAIT
    INT 16H ;COPY BYTE AL, CODE AH
    JNZ INPC1 ;CODE IF ZERO FLAG OFF
    XOR AX,AX ;NOTHING
    JMP SHORT INPC1
    INPC2:INT 16H
    INPC1:MOV SP,BP
    POP BP
    RET 4
    INPC endp
    sinpc ends


+ Reply to Thread