Author Topic: QMK how to get the pressed key?  (Read 3715 times)

0 Members and 1 Guest are viewing this topic.

Offline zer09

  • Thread Starter
  • Posts: 9
QMK how to get the pressed key?
« on: Sat, 18 November 2017, 21:12:52 »
Hello good day,

I just want know if there is way to get the pressed row and column position?

Thanks.

Offline zer09

  • Thread Starter
  • Posts: 9
Re: QMK how to get the pressed key?
« Reply #1 on: Sat, 18 November 2017, 23:28:45 »
I got the columns and rows using this.
Code: [Select]
  for (uint8_t c = 0; c < MATRIX_COLS; c++) {
    for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
      if (matrix_is_on(r, c)) {
        row_pressed = r;
        col_pressed = c;
        xprintf("r1:%d c1:%d \n", r, c);
        break;
      }
    }
  }

It give me the right result, but I don't know if it is the right way to this.
May be there is already a function to this, I don't want to reinvent the wheel.

Offline ErgoMacros

  • Posts: 313
  • Location: SF Bay Area
Re: QMK how to get the pressed key?
« Reply #2 on: Sun, 19 November 2017, 01:49:20 »
I don't know much, but in case it matters this will only find and report 1 key that's down.
I suppose that's OK if you're just typing one key at a time to map out a board.
Today's quote: '...“but then the customer successfully broke that.”

Offline zer09

  • Thread Starter
  • Posts: 9
Re: QMK how to get the pressed key?
« Reply #3 on: Sun, 19 November 2017, 02:54:09 »
Probably. I tried activating two keys, and the debug print show that it alternates between the two keys.

But I can't tell what will be the final result, I am still testing it on the breadboard.

Offline zer09

  • Thread Starter
  • Posts: 9
Re: QMK how to get the pressed key?
« Reply #4 on: Sun, 19 November 2017, 20:24:33 »