Fill screen of Hack computer..

.. while a key is pressed in keyboard.

So take a look at the program from a higher level:


And the implementation:
// Screen start address: 16384
// Screen end   address: 24575
 
// Store value 24575 at location: lastWord. 
// This will be global to our program.
@24575
D = A
@lastWord
M = D
 
(READKEYBOARDINPUT)
    @KBD
    D = M
    // If no key is pressed, jump to clear screen
    @CLEARSCREEN
    D;JEQ
 
    // If a key is pressed, jump to paint screen
    @PAINTSCREEN
    D;JGT
 
(PAINTSCREEN)
    @1
    D = -A
    @fillValue
    M = D
    @FILLSCREEN
    0;JMP
 
(CLEARSCREEN)
    @0
    D = A
    @fillValue
    M = D
 
(FILLSCREEN)
    @SCREEN
    D = A
    @currentWord
    M = D
 
    (FILLWORD)
        @fillValue
        D = M
        @currentWord
        A = M
        M = D
    (ENDFILLWORD)
 
    // Check if we filled whole screen
    @lastWord
    D = M
    @currentWord
    D = D - M
 
    // If we have, jump to END FILL SCREEN
    @ENDFILLSCREEN
    D;JEQ
 
    // Else, increment current word
    @currentWord
    M = M + 1
 
    // Jump to FILL WORD
    @FILLWORD
    0;JMP
(ENDFILLSCREEN)
 
@READKEYBOARDINPUT
0;JMP

And the program in action: