--- title: "The Keyboard Scanning Ports of the TS-2068" type: "article" slug: "explanation-of-some-of-the-zebra-fdd-to-the-tape-user" url: "http://localhost/article/explanation-of-some-of-the-zebra-fdd-to-the-tape-user/" markdown_url: "http://localhost/article/explanation-of-some-of-the-zebra-fdd-to-the-tape-user.md" published_at: "2024-03-24T00:59:35+00:00" modified_at: "2026-08-04T12:30:47+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Reprinted from CTM, March/April 1985 Some time ago when first attempting to translate a \"SPECTRUM\" program for operation in the TS-2068, I was exposed to a BASIC command that I had not see before — \"IN\". This aroused my curiosity and I began to work with different values and methods of writing the command as…" category: - name: "The Data Expansion" slug: "the-data-expansion" taxonomy: "category" url: "http://localhost/category/periodicals/the-data-expansion/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Reference" slug: "reference" taxonomy: "post_tag" url: "http://localhost/tag/reference/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "W. Fred Clabuesch" slug: "w-fred-clabuesch" taxonomy: "indiv" url: "http://localhost/indiv/w-fred-clabuesch/" publication_r: id: 50143 title: "The Data Expansion" type: "periodical" url: "http://localhost/periodical/the-data-expansion/" authors: "W. Fred Clabuesch" authors_r: - name: "W. Fred Clabuesch" slug: "w-fred-clabuesch" taxonomy: "indiv" url: "http://localhost/indiv/w-fred-clabuesch/" volume: "4" issue: "9" issues_articles: - id: 50242 title: "The Data Expansion v4 n9" type: "issue" url: "http://localhost/issue/the-data-expansion-v4-n9/" pages: "20-22" pubdate: "September 1987" archive_link: false --- # The Keyboard Scanning Ports of the TS-2068 *Reprinted from CTM, March/April 1985* Some time ago when first attempting to translate a “SPECTRUM” program for operation in the TS-2068, I was exposed to a BASIC command that I had not see before — “IN”. This aroused my curiosity and I began to work with different values and methods of writing the command as the translated programs would not move the character as I expected. This may be of interest if you are into writing games or want to set up cursor movements using keys other than the 5-6-7-8. It also has another advantage which I will discuss further in the article. ### What Does the “IN” Token Do? The token “IN” when used in a BASIC command addresses a ROM address and reads the value at that address. Each key of the keyboard has a specific address and value and in this way it is possible to determine which key has been depressed and then use that information to make the program react in a predetermined manner. For example, the line: ``` IF IN 63486=15 AND IN 63486=31 THEN LET n=n+1 ``` Reads the IN port location 63486 and looks at the value residing there. If the “5” key is not depressed, then a value of 31 will be read. As long as you hold down the “5” key, a value of 15 will be read at this location. The following is a table developed for the various keys of the TS-2068 keyboard and their values: #### IN Port Numbers | Value returned | 63486 | 64510 | 65022 | 65278 | 61438 | 57342 | 49150 | 32766 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 31 | NK | NK | NK | NK | NK | NK | NK | NK | | 30 | 1 | Q | A | CAP SH | 0 | P | | BREAK | | 29 | 2 | W | S | Z | 9 | O | L | SYM SH | | 27 | 3 | E | D | X | 8 | I | K | M | | 23 | 4 | R | F | C | 7 | U | J | N | | 15 | 5 | T | G | V | 6 | Y | H | B | NK = No key depressed = ENTER or return key CAP SH = Cap Shift Key BREAK = BREAK Key SYM SH = Symbol Shift Key The no-key values returned are different for most models of the Timex/Sinclair machines: 63 for the TS-1000, 31 for the TS-2068, 255 for the basic Spectrum, and 191 for the Spectrum III. To determine the returned value when a specific key is pressed, the following short program can be used and the value will be displayed as long as the key is held down: ``` 10 PRINT AT 11,14; IN (IN PORT NUMBER): GOTO 10 ``` If 63486 is inserted above for (IN PORT NUMBER), then 30 will be displayed when the 1 is depress, 29 when 2 is depressed, 27 when 3 is depressed, etc…. ### Summing Up You now have at your command three different methods of having the computer read input from the keyboard: (1) Use of the INKEY$ or INPUT tokens (2) Using the proper IN port number and value (3) By use of the STICK token to read the joystick port(s) This can be used to add variety to games or in the case of some data entry programs, not having to use the cursor arrows above the numbers. Connecting two IN ports by use of an “AND” could locate the movement on screen with the letters “i, j, k, l” for example. The IN port location 32766, value 30, could be worked into a program so that it sends the programs to an established routine when this key [BREAK] is pressed. This option has many possibilities for securing programs along with the ON ERR command(s). ### References for More Detailed Information On: In Port Scanning of the Keyboard (1) SYNTAX, Vol 5, No. 2, Feb. 84, [Keyboard Scanning](http://localhost/article/keyboard-scanning/) (2) ZX COMPUTING, Apr/May 1984, Pg. 9, INs and OUTs of Nuclear Attack.