public void keyrotate() {
        if (activeblock == null || activeblock.array == null || state != GameState.PLAYING) {
            return;
        }


        Block[][] lastblock = copy2D(activeblock.array);
        int lastrot = activeblock.rot;

        //Next rotation in array.
        if (activeblock.rot == blockdef[activeblock.type].length - 1) {
            activeblock.rot = 0;
        } else {
            activeblock.rot++;
        }

        activeblock.array = toBlock2D(blockdef[activeblock.type][activeblock.rot]);

        //Failsafe revert.
        if (!copy()) {
            activeblock.array = lastblock;
            activeblock.rot = lastrot;
        }
    }