[comp.sys.ibm.pc] Why CTRL-2 and CTRL-6 and not others???

mbb@cbnewsh.ATT.COM (martin.b.brilliant) (04/21/89)

From article <1673@blake.acs.washington.edu>, by djo7613@blake.acs.washington.edu (Dick O'Connor):
> 
> OK, keyboard scan experts, here's one for you:
> 
> While playing with macro-building in PC Tools Deluxe's Macro Editor,
> I tried all of the <CTRL>-number combinations using the top row number
> keys and could only assign CTRL-2 and CTRL-6 as hot-keys.  It didn't
> seem to recognize the other eight potential CTRL-digit combinations.

I bet it has nothing to do with scan codes.  I would guess it depends
on the definitions of control characters.

In the ASCII code table there are 32 control characters with ASCII
numeric values of 0 to 31 (decimal).  Control characters 1 through 26
are obtained by hitting CTRL-A through CTRL-Z, that is, the CTRL key
with the printable character whose ASCII code is 64 plust the code for
the control character.  That leaves 6 control characters to be based on
non-alphabetic printable characters.

The character preceding A is @ and so CTRL-@ is the 0 control
character, but since @ is SHIFT-2 you get it with CTRL-2 (to make it
easier, CTRL-SHIFT-2 is not required). The others are based on the
characters next five after Z in the ASCII code table, most of which can
be typed without the SHIFT key.  The exceptions are ^ which is SHIFT-6,
so you get CTRL-^ by typing CTRL-6, and _ which is SHIFT-minus so you
would probably get CTRL-_ by hitting CTRL-minus.

M. B. Brilliant					Marty
AT&T-BL HO 3D-520	(201) 949-1858
Holmdel, NJ 07733	att!cbnewsh!mbb or mbb@cbnewsh.ATT.COM

Disclaimer: Opinions stated herein are mine unless and until my employer
	    explicitly claims them; then I lose all rights to them.

ralf@b.gp.cs.cmu.edu (Ralf Brown) (04/21/89)

In article <1673@blake.acs.washington.edu> djo7613@blake.acs.washington.edu (Dick O'Connor) writes:
}While playing with macro-building in PC Tools Deluxe's Macro Editor,
}I tried all of the <CTRL>-number combinations using the top row number
}keys and could only assign CTRL-2 and CTRL-6 as hot-keys.  It didn't
}seem to recognize the other eight potential CTRL-digit combinations.

These are the only ^number keys recognized by the BIOS, because they are
really ctrl-@ (ASCII NUL) and ctrl-caret (ASCII 30), but there are no such
characters as ctrl-ampersand, for example.  PC-Tools probably accepts only
keystrokes which the BIOS recognizes.
-- 
{harvard,uunet,ucbvax}!b.gp.cs.cmu.edu!ralf -=-=- AT&T: (412)268-3053 (school) 
ARPA: RALF@B.GP.CS.CMU.EDU |"Tolerance means excusing the mistakes others make.
FIDO: Ralf Brown at 129/31 | Tact means not noticing them." --Arthur Schnitzler
BITnet: RALF%B.GP.CS.CMU.EDU@CMUCCVMA -=-=- DISCLAIMER? I claimed something?
-- 

everett@hpcvlx.HP.COM (Everett Kaser) (04/21/89)

 djo7613@blake.acs.washington.edu (Dick O'Connor) writes...

>While playing with macro-building in PC Tools Deluxe's Macro Editor,
>I tried all of the <CTRL>-number combinations using the top row number
>keys and could only assign CTRL-2 and CTRL-6 as hot-keys.  It didn't
>seem to recognize the other eight potential CTRL-digit combinations.
>I don't know much about XT keyboard scan codes (it's a Zenith Z159, if
>it matters).  Is this a result of something PC Tools is doing, or is it
>related to those particular scan codes regardless of application?
>Dick O'Connor

No, it's normal to all PC's.  If you look at an ASCII character table,
you should notice (with a little prodding :-) that the ASCII character codes
that are generated when you hold down the CTRL key are simply the ASCII
code of the key WITHOUT the CTRL key, minus 64.  Yea, I know that was a
poorly written sentence and difficult to understand.  So, a small example:

    -------CTRL--------          -------NORMAL--------
     char  ASCII-code             char   ASCII-code
      ^@     0                     @       64
      ^A     1                     A       65
      ^B     2                     B       66
      ^C     3                     C       67
          .                            .
          .                            .
          .                            .
      ^Z     26                    Z       90
      ^[     27                    [       91
      ^\     28                    \       92
      ^]     29                    ]       93
      ^^     30                    ^       94
      ^_     31                    _       95

Now, the PC BIOS pretty much ignores the shift key when the CTRL key is
down.  The BIOS only uses one 'shift' key (SHIFT, CTRL, ALT) at a time, and
CTRL seems to take precedence over SHIFT.  So, CTRL-A is the same as CTRL-a
(CTRL-SHIFT-A) and CTRL-2 is the same as CTRL-@ (CTRL-SHIFT-2).  Ditto for
CTRL-6 versus CTRL-SHIFT-6 = CTRL-^.  None of the other number keys have
a symbol as the shifted character that lies in the range from 64 to 95.

Understand now?  Perfectly simple?  Nothing is simple when it comes to
keyboards.  Trust me.  I know.  :-)

Everett Kaser
!hplabs!hp-pcd!everett
everett%hpcvlx@hplabs.hp.com