diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index a3fe559f3..97a8f1cd8 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -61,39 +61,45 @@ along with this program. If not, see .
# include "visualizer/visualizer.h"
#endif
-
#ifdef MATRIX_HAS_GHOST
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata){
matrix_row_t out = 0;
- for (int col = 0; col < MATRIX_COLS; col++) {
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ //read each key in the row data and check if the keymap defines it as a real key
if (pgm_read_byte(&keymaps[0][row][col]) && (rowdata & (1<