Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/grammy/mod.ts>InlineKeyboard#toTransposed

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

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

Note that inline 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 an inline 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  ]