Skip to main content
Module

x/grammy/mod.ts>Keyboard#toTransposed

The Telegram Bot Framework.
Very Popular
Go to Latest
method Keyboard.prototype.toTransposed
import { Keyboard } from "https://deno.land/x/grammy@v1.22.4/mod.ts";

Creates a new keyboard that contains the transposed grid of buttons of this keyboard. This means that the resulting keyboard has the rows and columns flipped.

Note that buttons can only span multiple columns, but never multiple rows. This means that if the given arrays have different lengths, some buttons might flow up in the layout. In these cases, transposing a keyboard a second time will not undo the first transposition.

Here are some examples.

original    transposed
[  a  ]  ~> [  a  ]

            [  a  ]
[a b c]  ~> [  b  ]
            [  c  ]

[ a b ]     [a c e]
[ c d ]  ~> [ b d ]
[  e  ]

[ a b ]     [a c d]
[  c  ]  ~> [ b e ]
[d e f]     [  f  ]