Key output method for keyboards
This application is a continuation of application Ser. No. 07/081,529, filed Aug. 3, 1987, which is a continuation of application Ser. No. 06/758,523, filed July 24, 1985, now abandoned. 
    
    
     BACKGROUND OF THE INVENTION 
     The present invention relates to a keyboard with N-key rollover, and more particularly to a key output method in a keyboard, which requires no diodes for preventing a roundabout current. 
     FIG. 4 of the accompanying drawings is a block diagram of a keyboard input device having an N-key rollover function. A key matrix 1 is composed of a matrix of keys 2 and diodes 3 connected in series thereto, respectively. The key matrix 1 has columns 1a connected to a decoder 4. The decoder 4 and lines 1b of the key matrix 1 are connected to a CPU 5. 
     A ROM 6 storing key codes and a program for issuing them is connected to the CPU 5. 
     When one of the keys is depressed, a scanning signal from the decoder 4 is applied through one of the columns 1a, the depressed key and the diode connected thereto, and a corresponding one of the lines 1b, to the CPU 5. The CPU 5 detects the depressed key based on the scanning position (column position) and the line position. A key code corresponding to the detected key is then read out of the ROM 6 and issued. 
     While the keyboard is operated on at a high speed, a plurality of keys are sometimes depressed concurrently. The N-key rollover function allows all output signals from the depressed keys to be issued. This rollover function requires the use of diodes 3 associated respectively with the keys 2 for the reason that when three or more keys sharing common rows and columns are concurrently depressed, a roundabout current flows to let an undepressed key be detected as being a turned-on key. This condition is known conventionally as &#34;a phantom switch condition&#34;, since depression of three keys at three corners of a rectangle of rows and columns causes erroneous detection of the fourth corner as being depressed. 
     The keyboard with the N-key rollover function is therefore of a high cost since as many diodes are required as there are keys. 
     SUMMARY OF THE INVENTION 
     With the foregoing problem in view, it is an object of the present invention to achieve a cost reduction by eliminating diodes for preventing a roundabout current in a keyboard with N-key rollover. 
     According to a key output method for a keyboard with N-key rollover, when first and second keys on the same column are detected as being depressed and then a third key on the same line as one of the first and second keys is detected as being depressed, or when first and second keys on the same line are detected as being depressed and then a third key on the same column as one of the first and second keys is detected as being depressed, a key code for the third key and a key code for a fourth key detected in error upon depression of the third key are prevented from being issued. 
     The above and other objects, features and advantages of the present invention will become more apparent from the following description when taken in conjunction with the accompanying drawings in which a preferred embodiment of the present invention is shown by way of illustrative example. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram of a keyboard input device according to the present invention; 
     FIG. 2 is a set of diagrams showing contents of a RAM; 
     FIG. 3 is a flowchart of successive steps of a key output method of the invention; and 
     FIG. 4 is a block diagram of a conventional keyboard input device with an N-key rollover function. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     Like or identical parts shown in FIG. 1 are denoted by like or identical reference characters in FIG. 4 and will not be described in detail. 
     As shown in FIG. 1, the CPU 5 includes a RAM 7 for storing items of positional information respectively for the keys of the key matrix 1. When one of the keys is depressed, a flag in the RAM 7 corresponding to the depressed key is set to &#34;1&#34;. When the depressed key is released, the flag is reset to &#34;0&#34;. 
     When the keys Nos. 2, 14, 17 as shown in FIG. 2(a) are concurrently depressed (phantom switch condition), the corresponding flags in the RAM 7 are set as shown in FIG. 2(b). With no diodes for preventing a roundabout current, the key No. 5 in addition to the keys Nos. 2, 14, 17 is also detected as being turned on. 
     According to an embodiment of the present invention, the keyboard output device will operate as described below when the keys Nos. 2, 14, 17 are concurrently depressed as shown in FIGS. 2(a) and (b). 
     If the key No. 2 is first detected according to the timing of key scanning, then the key No. 14 on the same column as the key No. 2 is also detected. When the CPU 5 processes the key No. 2 at first, the memory in the RAM 7 corresponding to the key No. 2 is set to &#34;1&#34;. Then, whether an output should be issued from the key No. 2 or not is checked by ascertaining whether there is a flag &#34;1&#34; in the RAM 7. 
     Since the key No. 2 is the sole key first processed and there are no other detected keys (represented by the flag &#34;1&#34;) on the same line and column as the key No. 2, a key code corresponding to the key No. 2 in the ROM 6 is read and issued out. 
     Then, the key No. 14 is processed in the CPU 5, and the memory in the RAM 7 corresponding to the key No. 14 is set to &#34;1&#34;. Whether an output should be issued from the key No. 14 or not is checked by ascertaining whether there is a flag &#34;1&#34; in the RAM 7. 
     Although there are no other depressed keys on the same line as the key No. 14, there is the flag &#34;1&#34; for the key No. 2 previously detected on the same column. Then, whether there are other detected keys (represented by the flag &#34;1&#34;) on the same line as the key No. 2 is determined. As there are no such detected keys, a key code corresponding to the key No. 14 in the ROM 6 is read and issued out. Then, the key No. 17 is detected and a flag &#34;1&#34; is set in the RAM 6. Since the keys Nos. 2 and 14 remain depressed at this time, a scanning signal is applied through from the key No. 17 through the keys Nos. 14 and 2 to the CPU 5 which now detects as if the undepressed key No. 5 were depressed due to a roundabout current. Therefore, the keys Nos. 5 and 17 are also detected. The CPU 5 then processes the keys Nos. 5 and 17 one after the other. 
     However, no output from these keys Nos. 5 and 17 is issued no matter which key may be processed first. More specifically, if the key No. 17 is processed first, then there are three flags &#34;1&#34; in the RAM 7. The flag &#34;1&#34; for the key No. 14 is present on the same line as the key No. 17, and the flag &#34;1&#34; for the key No. 2 is present on the same column as the key No. 14, so that no key code for the key No. 17 is issued. If the key No. 5 is processed first, then a memory corresponding to the key No. 5 in the RAM 6 is set to &#34;1&#34;, and there are four flags &#34;4&#34; in the RAM 6. The flags &#34;1&#34; for the keys Nos. 2 and 17 are present on the same column and line as the key No. 5, and the flag &#34;1&#34; for the key No. 14 is present on the same column as the key No. 2 or the same line as the key No. 17, so that no key code for the key No. 5 is issued. 
     As described above, when a plurality of keys are concurrently depressed to cause a phantom condition to arise, the key codes of the first two keys depressed will always be issued, while no key code for the third key and additional keys depressed will be issued. When keys are depressed key and following will be issued. 
     When keys are depressed in patterns as illustrated in FIGS. 2(c) and (d), there no undepressed keys which are detected as being depressed, as with the key No. 5 in FIG. 2(b), and hence key codes for all of the depressed keys are issued. 
     The above operation will be described with reference to the flowchart of FIG. 3. 
     If two keys such as A, B are not detected or one of the two keys is detected, the flag in the memory corresponding to a next detected key C is set to &#34;1&#34;, and a key code for the key C is issued. 
     If the keys A, B are both detected with their key codes issued and then the key C is detected, i.e., if the keys A, B, C are concurrently depressed, then the flag in the memory corresponding to the key C is set to &#34;1&#34; first. Thereafter, whether either of the keys A or B is on the same line as the key C is checked by ascertaining whether there is a flag &#34;1&#34; in the memory in the RAM 7. If either of the keys A or B is on the same line as the key C, then whether the key A of the flag &#34;1&#34; is on the same column as the key B is checked. If the key A is on the same column as the key B, then no key code for the key C is issued. 
     If either of the keys A or B is not on the same line as the key C, then whether either of the keys A or B is on the same column as the key C is checked. If either of the keys A or B is not on the same column as the key C, the key code for the key C is issued. If either of the keys A or B is on the same column as the key C, then whether the key A is on the same line as the key B is checked. If the key A is on the same line as the key B, then the key code for the key C is not issued, and if the key A is not on the same line as the key B, then the key code for the key C is issued. Where no key code is issued for the key C, a next fourth key is detected. The fourth key is also checked according to the above checking process, and its key code is not issued. 
     With the present invention, the keyboard output device is essentially operated in a 2-key rollover mode (lockout) only when keys are depressed in a phantom switch condition to cause a malfunction, and in an N-key rollover mode in other occasions. The keyboard is of a low cost as there are no diodes employed. 
     Although a certain preferred embodiment has been shown and described, it should be understood that many changes and modifications may be made therein without departing from the scope of the appended claims.